remem-mcp 0.6.6 → 0.6.8

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 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(input.cwd ?? toolInput.workdir ?? process.cwd());
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)}`;
@@ -5184,6 +5195,14 @@ function hookPostToolUse(dbPath) {
5184
5195
  process.stdout.write(JSON.stringify({}));
5185
5196
  return;
5186
5197
  }
5198
+ const bashIgnorePatterns = loadCaptureExclusions(cwd);
5199
+ if (bashIgnorePatterns.length > 0 && shouldExcludeCommand(command, bashIgnorePatterns)) {
5200
+ logToFile(
5201
+ `PostToolUse: skipping Bash \u2014 command matches capture exclusion: ${command.slice(0, 80)}`
5202
+ );
5203
+ process.stdout.write(JSON.stringify({}));
5204
+ return;
5205
+ }
5187
5206
  let db;
5188
5207
  try {
5189
5208
  db = new Database8(dbPath);
@@ -6166,6 +6185,67 @@ function hookPreToolUse(dbPath) {
6166
6185
  }
6167
6186
  });
6168
6187
  }
6188
+ var exclusionCache = /* @__PURE__ */ new Map();
6189
+ var MAX_ANCESTORS = 20;
6190
+ function parseCaptureExclusions(content) {
6191
+ const sectionMatch = content.match(/^\[capture\]\s*$/m);
6192
+ if (!sectionMatch) return [];
6193
+ const sectionStart = sectionMatch.index + sectionMatch[0].length;
6194
+ const nextSection = content.slice(sectionStart).match(/^\[.+\]\s*$/m);
6195
+ const sectionText = nextSection ? content.slice(sectionStart, sectionStart + nextSection.index) : content.slice(sectionStart);
6196
+ const pathsMatch = sectionText.match(/ignore_paths\s*=\s*\[([^\]]*)\]/);
6197
+ if (!pathsMatch) return [];
6198
+ const items = pathsMatch[1].match(/"([^"]+)"/g);
6199
+ if (!items) return [];
6200
+ return items.map((item) => item.replace(/"/g, ""));
6201
+ }
6202
+ function loadCaptureExclusions(cwd) {
6203
+ const cached = exclusionCache.get(cwd);
6204
+ if (cached !== void 0) return cached;
6205
+ let patterns = [];
6206
+ try {
6207
+ let dir = cwd;
6208
+ for (let i = 0; i < MAX_ANCESTORS; i++) {
6209
+ const markerPath = join8(dir, ".remem.toml");
6210
+ if (existsSync7(markerPath)) {
6211
+ const content = readFileSync5(markerPath, "utf-8");
6212
+ patterns = parseCaptureExclusions(content);
6213
+ break;
6214
+ }
6215
+ const parent = dirname4(dir);
6216
+ if (parent === dir) break;
6217
+ dir = parent;
6218
+ }
6219
+ } catch {
6220
+ }
6221
+ exclusionCache.set(cwd, patterns);
6222
+ return patterns;
6223
+ }
6224
+ function shouldExcludePath(filePath, ignorePatterns) {
6225
+ if (ignorePatterns.length === 0) return false;
6226
+ const normalized = filePath.replace(/\\/g, "/");
6227
+ const segments = normalized.split("/");
6228
+ for (const pattern of ignorePatterns) {
6229
+ if (pattern.startsWith("*.")) {
6230
+ if (normalized.endsWith(pattern.slice(1))) return true;
6231
+ continue;
6232
+ }
6233
+ if (segments.includes(pattern)) return true;
6234
+ }
6235
+ return false;
6236
+ }
6237
+ function shouldExcludeCommand(command, ignorePatterns) {
6238
+ if (ignorePatterns.length === 0) return false;
6239
+ for (const pattern of ignorePatterns) {
6240
+ if (pattern.startsWith("*.")) continue;
6241
+ const re = new RegExp(`(^|[\\s/])${escapeRegex(pattern)}([\\s/]|$)`);
6242
+ if (re.test(command)) return true;
6243
+ }
6244
+ return false;
6245
+ }
6246
+ function escapeRegex(s) {
6247
+ return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
6248
+ }
6169
6249
  function isNoiseCommand(command) {
6170
6250
  const lower = command.toLowerCase().trim();
6171
6251
  if (/\/nonexistent|\/tmp\/test|\/test\/fake|example\.ts|foo\.ts|bar\.ts/.test(lower)) return true;