claude-memory-layer 1.0.12 → 1.0.14

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/index.js CHANGED
@@ -7037,16 +7037,28 @@ var SessionHistoryImporter = class {
7037
7037
  };
7038
7038
  const onProgress = options.onProgress;
7039
7039
  onProgress?.({ phase: "scan", message: "Scanning for session files..." });
7040
- const projectDir = await this.findProjectDir(projectPath);
7041
- if (!projectDir) {
7040
+ const projectDirs = await this.findProjectDirs(projectPath);
7041
+ if (projectDirs.length === 0) {
7042
7042
  result.errors.push(`Project directory not found for: ${projectPath}`);
7043
7043
  return result;
7044
7044
  }
7045
- const sessionFiles = await this.findSessionFiles(projectDir);
7045
+ const allSessionFiles = [];
7046
+ for (const dir of projectDirs) {
7047
+ const files = await this.findSessionFiles(dir);
7048
+ allSessionFiles.push(...files);
7049
+ }
7050
+ const sessionFiles = [...new Set(allSessionFiles)];
7046
7051
  result.totalSessions = sessionFiles.length;
7047
- onProgress?.({ phase: "scan", message: `Found ${sessionFiles.length} sessions in ${path4.basename(projectDir)}` });
7052
+ onProgress?.({
7053
+ phase: "scan",
7054
+ message: `Found ${sessionFiles.length} sessions in ${projectDirs.length} matched project folder(s)`
7055
+ });
7048
7056
  if (options.verbose) {
7049
- console.log(`Found ${sessionFiles.length} session files in ${projectDir}`);
7057
+ console.log(`Matched project folders:`);
7058
+ for (const dir of projectDirs) {
7059
+ console.log(` - ${dir}`);
7060
+ }
7061
+ console.log(`Found ${sessionFiles.length} session files across matched folders`);
7050
7062
  }
7051
7063
  for (let i = 0; i < sessionFiles.length; i++) {
7052
7064
  const sessionFile = sessionFiles[i];
@@ -7246,22 +7258,37 @@ var SessionHistoryImporter = class {
7246
7258
  return result;
7247
7259
  }
7248
7260
  /**
7249
- * Find project directory from project path
7261
+ * Find project directories from project path.
7262
+ * Supports wrappers (e.g. happy) that append extra path segments in folder names.
7250
7263
  */
7251
- async findProjectDir(projectPath) {
7264
+ async findProjectDirs(projectPath) {
7252
7265
  const projectsDir = path4.join(this.claudeDir, "projects");
7253
7266
  if (!fs5.existsSync(projectsDir)) {
7254
- return null;
7267
+ return [];
7255
7268
  }
7256
7269
  const projectDirs = fs5.readdirSync(projectsDir).map((name) => path4.join(projectsDir, name)).filter((p) => fs5.statSync(p).isDirectory());
7257
- const normalizedPath = projectPath.replace(/\//g, "-").replace(/^-/, "");
7258
- for (const dir of projectDirs) {
7270
+ const normalizedPath = projectPath.replace(/\/+/g, "/").replace(/\/$/, "");
7271
+ const normalizedDashed = normalizedPath.replace(/\//g, "-").replace(/^-/, "");
7272
+ const baseName = path4.basename(normalizedPath);
7273
+ const scored = projectDirs.map((dir) => {
7259
7274
  const dirName = path4.basename(dir);
7260
- if (dirName.includes(normalizedPath) || normalizedPath.includes(dirName)) {
7261
- return dir;
7262
- }
7263
- }
7264
- return projectDirs.length > 0 ? projectDirs[0] : null;
7275
+ let score = 0;
7276
+ if (dirName.includes(normalizedDashed))
7277
+ score += 100;
7278
+ if (normalizedDashed.includes(dirName))
7279
+ score += 80;
7280
+ if (baseName && dirName.includes(baseName))
7281
+ score += 30;
7282
+ const pathTokens = normalizedDashed.split("-").filter(Boolean);
7283
+ const tokenHits = pathTokens.filter((t) => t.length >= 3 && dirName.includes(t)).length;
7284
+ score += Math.min(tokenHits, 20);
7285
+ return { dir, score, dirName };
7286
+ }).filter((x) => x.score > 0).sort((a, b) => b.score - a.score);
7287
+ if (scored.length === 0)
7288
+ return [];
7289
+ const top = scored[0].score;
7290
+ const threshold = Math.max(30, top - 25);
7291
+ return scored.filter((x) => x.score >= threshold).map((x) => x.dir);
7265
7292
  }
7266
7293
  /**
7267
7294
  * Find all JSONL session files in a directory
@@ -7296,10 +7323,7 @@ var SessionHistoryImporter = class {
7296
7323
  const sessions = [];
7297
7324
  let projectDirs = [];
7298
7325
  if (projectPath) {
7299
- const projectDir = await this.findProjectDir(projectPath);
7300
- if (projectDir) {
7301
- projectDirs = [projectDir];
7302
- }
7326
+ projectDirs = await this.findProjectDirs(projectPath);
7303
7327
  } else {
7304
7328
  const projectsDir = path4.join(this.claudeDir, "projects");
7305
7329
  if (fs5.existsSync(projectsDir)) {
@@ -9215,7 +9239,7 @@ function getHooksConfig(pluginPath) {
9215
9239
  };
9216
9240
  }
9217
9241
  var program = new Command();
9218
- program.name("claude-memory-layer").description("Claude Code Memory Plugin CLI").version("1.0.12");
9242
+ program.name("claude-memory-layer").description("Claude Code Memory Plugin CLI").version("1.0.14");
9219
9243
  program.command("install").description("Install hooks into Claude Code settings").option("--path <path>", "Custom plugin path (defaults to auto-detect)").action(async (options) => {
9220
9244
  try {
9221
9245
  const pluginPath = options.path || getPluginPath();