claude-recall 0.5.0 → 0.5.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-recall",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Persistent memory for Claude Code with automatic capture via hooks and MCP server",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -5,14 +5,33 @@ const path = require('path');
5
5
 
6
6
  console.log('\nšŸ“‹ Setting up .claude/ directory structure...\n');
7
7
 
8
- try {
9
- // Determine project root (where package.json is)
10
- const projectRoot = process.cwd();
8
+ /**
9
+ * Find the project root by traversing up from node_modules/claude-recall/scripts/
10
+ * This is more reliable than process.cwd() during npm install
11
+ */
12
+ function findProjectRoot() {
13
+ // During npm install, this script is at: <project>/node_modules/claude-recall/scripts/postinstall-claude-md.js
14
+ // We need to go up 3 levels to reach <project>/
15
+ let currentDir = __dirname;
16
+
17
+ // Go up from scripts/ -> claude-recall/ -> node_modules/ -> <project>/
18
+ const projectRoot = path.join(currentDir, '..', '..', '..');
11
19
 
12
- // Check if we're in a project (has package.json)
20
+ console.log(` šŸ” Detected project root: ${projectRoot}`);
21
+
22
+ // Verify this is actually a project root
13
23
  const packageJsonPath = path.join(projectRoot, 'package.json');
14
24
  if (!fs.existsSync(packageJsonPath)) {
15
- console.log(' Not in a project directory, skipping .claude/ setup');
25
+ console.log(' āš ļø No package.json found at project root, skipping .claude/ setup');
26
+ return null;
27
+ }
28
+
29
+ return projectRoot;
30
+ }
31
+
32
+ try {
33
+ const projectRoot = findProjectRoot();
34
+ if (!projectRoot) {
16
35
  process.exit(0);
17
36
  }
18
37
 
@@ -26,34 +45,63 @@ try {
26
45
 
27
46
  // Source paths (in node_modules/claude-recall/.claude/)
28
47
  const sourceClaudeDir = path.join(__dirname, '..', '.claude');
29
- const sourceClaude Md = path.join(sourceClaudeDir, 'CLAUDE.md');
48
+ const sourceClaudeMd = path.join(sourceClaudeDir, 'CLAUDE.md');
30
49
  const sourceAgentsDir = path.join(sourceClaudeDir, 'agents');
31
50
  const sourceSkillsDir = path.join(sourceClaudeDir, 'skills');
32
51
 
52
+ console.log(` šŸ“‚ Source directory: ${sourceClaudeDir}`);
53
+
33
54
  // Create directories
34
55
  [claudeDir, agentsDir, skillsDir, memoryManagementDir, referencesDir].forEach(dir => {
35
56
  if (!fs.existsSync(dir)) {
36
57
  fs.mkdirSync(dir, { recursive: true });
58
+ console.log(` šŸ“ Created ${path.relative(projectRoot, dir)}/`);
37
59
  }
38
60
  });
39
61
 
40
- // Copy CLAUDE.md if source exists and target doesn't
41
- if (fs.existsSync(sourceClaude Md) && !fs.existsSync(claudeMdPath)) {
42
- fs.copyFileSync(sourceClaude Md, claudeMdPath);
43
- console.log(' āœ… Created .claude/CLAUDE.md');
62
+ // Handle CLAUDE.md - merge if exists, create if not
63
+ if (fs.existsSync(sourceClaudeMd)) {
64
+ if (fs.existsSync(claudeMdPath)) {
65
+ // CLAUDE.md already exists - prepend Skills reference
66
+ console.log(' ā„¹ļø Existing CLAUDE.md found, preserving content');
67
+ const existingContent = fs.readFileSync(claudeMdPath, 'utf-8');
68
+ const sourceContent = fs.readFileSync(sourceClaudeMd, 'utf-8');
69
+
70
+ // Check if Skills reference already exists
71
+ if (!existingContent.includes('Claude Code Skills Integration') &&
72
+ !existingContent.includes('.claude/skills/memory-management')) {
73
+ const prependText = `# Claude Recall - Skills Integration\n\n` +
74
+ `**Note**: Claude Recall now uses Claude Code Skills for better memory management.\n` +
75
+ `See [.claude/skills/memory-management/SKILL.md](./.claude/skills/memory-management/SKILL.md) for details.\n\n` +
76
+ `---\n\n`;
77
+
78
+ fs.writeFileSync(claudeMdPath, prependText + existingContent);
79
+ console.log(' āœ… Added Skills reference to existing CLAUDE.md');
80
+ } else {
81
+ console.log(' ā­ļø CLAUDE.md already has Skills reference, skipping');
82
+ }
83
+ } else {
84
+ // No CLAUDE.md exists - create new one
85
+ fs.copyFileSync(sourceClaudeMd, claudeMdPath);
86
+ console.log(' āœ… Created .claude/CLAUDE.md');
87
+ }
44
88
  }
45
89
 
46
90
  // Copy agents directory if exists
47
91
  if (fs.existsSync(sourceAgentsDir)) {
48
- const agentFiles = fs.readdirSync(sourceAgentsDir);
92
+ const agentFiles = fs.readdirSync(sourceAgentsDir).filter(f => f.endsWith('.md'));
93
+ let copiedCount = 0;
49
94
  agentFiles.forEach(file => {
50
95
  const sourcePath = path.join(sourceAgentsDir, file);
51
96
  const destPath = path.join(agentsDir, file);
52
- if (!fs.existsSync(destPath)) {
97
+ if (!fs.existsSync(destPath) && fs.statSync(sourcePath).isFile()) {
53
98
  fs.copyFileSync(sourcePath, destPath);
99
+ copiedCount++;
54
100
  }
55
101
  });
56
- console.log(' āœ… Created .claude/agents/');
102
+ if (copiedCount > 0) {
103
+ console.log(` āœ… Created .claude/agents/ (${copiedCount} file${copiedCount > 1 ? 's' : ''})`);
104
+ }
57
105
  }
58
106
 
59
107
  // Copy skills directory if exists
@@ -61,23 +109,35 @@ try {
61
109
  // Copy SKILL.md
62
110
  const skillMdSource = path.join(sourceSkillsDir, 'memory-management', 'SKILL.md');
63
111
  const skillMdDest = path.join(memoryManagementDir, 'SKILL.md');
64
- if (fs.existsSync(skillMdSource) && !fs.existsSync(skillMdDest)) {
65
- fs.copyFileSync(skillMdSource, skillMdDest);
66
- console.log(' āœ… Created .claude/skills/memory-management/SKILL.md');
112
+ if (fs.existsSync(skillMdSource)) {
113
+ if (!fs.existsSync(skillMdDest)) {
114
+ fs.copyFileSync(skillMdSource, skillMdDest);
115
+ console.log(' āœ… Created .claude/skills/memory-management/SKILL.md');
116
+ } else {
117
+ console.log(' ā­ļø SKILL.md already exists, skipping');
118
+ }
119
+ } else {
120
+ console.log(' āš ļø Warning: SKILL.md not found in source');
67
121
  }
68
122
 
69
123
  // Copy reference files
70
124
  const sourceReferencesDir = path.join(sourceSkillsDir, 'memory-management', 'references');
71
125
  if (fs.existsSync(sourceReferencesDir)) {
72
- const refFiles = fs.readdirSync(sourceReferencesDir);
126
+ const refFiles = fs.readdirSync(sourceReferencesDir).filter(f => f.endsWith('.md'));
127
+ let copiedCount = 0;
73
128
  refFiles.forEach(file => {
74
129
  const sourcePath = path.join(sourceReferencesDir, file);
75
130
  const destPath = path.join(referencesDir, file);
76
- if (!fs.existsSync(destPath)) {
131
+ if (!fs.existsSync(destPath) && fs.statSync(sourcePath).isFile()) {
77
132
  fs.copyFileSync(sourcePath, destPath);
133
+ copiedCount++;
78
134
  }
79
135
  });
80
- console.log(' āœ… Created .claude/skills/memory-management/references/');
136
+ if (copiedCount > 0) {
137
+ console.log(` āœ… Created .claude/skills/memory-management/references/ (${copiedCount} file${copiedCount > 1 ? 's' : ''})`);
138
+ }
139
+ } else {
140
+ console.log(' āš ļø Warning: references/ directory not found in source');
81
141
  }
82
142
  }
83
143