@contextmirror/claude-memory 0.2.0 → 0.2.2
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.js +168 -0
- package/dist/license/index.d.ts +39 -0
- package/dist/license/index.js +153 -0
- package/dist/license/types.d.ts +37 -0
- package/dist/license/types.js +4 -0
- package/dist/mcp/server.js +217 -12
- package/dist/scanner/contextGenerator.d.ts +7 -0
- package/dist/scanner/contextGenerator.js +97 -10
- package/dist/scanner/projectScanner.js +59 -15
- package/dist/setup/setupWizard.js +81 -4
- package/dist/types/index.d.ts +36 -1
- package/dist/types/index.js +41 -2
- package/landing/index.html +478 -169
- package/package.json +2 -1
- package/.claude/settings.local.json +0 -10
|
@@ -6,14 +6,17 @@
|
|
|
6
6
|
* 2. Offers to generate CLAUDE.md for projects without one
|
|
7
7
|
* 3. Auto-configures MCP in ~/.claude.json
|
|
8
8
|
*/
|
|
9
|
-
import { readFileSync, writeFileSync, existsSync } from 'fs';
|
|
9
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'fs';
|
|
10
10
|
import { join } from 'path';
|
|
11
11
|
import { homedir } from 'os';
|
|
12
12
|
import { createInterface } from 'readline';
|
|
13
13
|
import { scanProjects } from '../scanner/projectScanner.js';
|
|
14
14
|
import { generateGlobalContext, writeGlobalContext } from '../scanner/contextGenerator.js';
|
|
15
15
|
import { generateBriefing, briefingToClaudeMd } from '../briefing/briefingGenerator.js';
|
|
16
|
+
import { DEFAULT_MEMORY_CONFIG } from '../types/index.js';
|
|
16
17
|
const CLAUDE_JSON_PATH = join(homedir(), '.claude.json');
|
|
18
|
+
const MEMORY_DIR = join(homedir(), '.claude-memory');
|
|
19
|
+
const CONFIG_PATH = join(MEMORY_DIR, 'config.json');
|
|
17
20
|
const MCP_SERVER_CONFIG = {
|
|
18
21
|
command: 'claude-memory',
|
|
19
22
|
args: ['mcp'],
|
|
@@ -22,12 +25,33 @@ const MCP_SERVER_CONFIG = {
|
|
|
22
25
|
* Run the setup wizard
|
|
23
26
|
*/
|
|
24
27
|
export async function runSetupWizard(options = {}) {
|
|
25
|
-
const { projectsDir
|
|
28
|
+
const { projectsDir: providedDir, skipMcp = false, skipBriefing = false, interactive = true, } = options;
|
|
26
29
|
console.log('');
|
|
27
30
|
console.log('╔══════════════════════════════════════════════════════════╗');
|
|
28
31
|
console.log('║ 🧠 Claude Memory - Setup Wizard ║');
|
|
29
32
|
console.log('╚══════════════════════════════════════════════════════════╝');
|
|
30
33
|
console.log('');
|
|
34
|
+
// Determine projects directory
|
|
35
|
+
let projectsDir = providedDir || guessProjectsDir();
|
|
36
|
+
if (!projectsDir) {
|
|
37
|
+
console.log('📍 Step 0: Locate your projects\n');
|
|
38
|
+
console.log(' Could not auto-detect your projects directory.');
|
|
39
|
+
console.log(' Common locations like ~/Projects, ~/Code, ~/dev were not found.\n');
|
|
40
|
+
if (interactive) {
|
|
41
|
+
const answer = await ask(' Enter your projects directory path: ');
|
|
42
|
+
if (!answer || !existsSync(answer)) {
|
|
43
|
+
console.log('\n ❌ Invalid directory. Please run:');
|
|
44
|
+
console.log(' claude-memory setup -d /path/to/your/projects');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
projectsDir = answer;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
console.log(' ❌ Cannot continue without a projects directory.');
|
|
51
|
+
console.log(' Run: claude-memory setup -d /path/to/your/projects');
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
31
55
|
// Step 1: Find projects
|
|
32
56
|
console.log('📍 Step 1: Scanning for projects\n');
|
|
33
57
|
console.log(` Looking in: ${projectsDir}`);
|
|
@@ -104,6 +128,45 @@ export async function runSetupWizard(options = {}) {
|
|
|
104
128
|
console.log(' }');
|
|
105
129
|
}
|
|
106
130
|
}
|
|
131
|
+
// Step 5: Configure auto-detection
|
|
132
|
+
console.log('\n📍 Step 5: Configure new project detection\n');
|
|
133
|
+
if (interactive) {
|
|
134
|
+
console.log(' When you create a new folder in your projects directory,');
|
|
135
|
+
console.log(' Claude can automatically detect it and offer to set it up.');
|
|
136
|
+
console.log('');
|
|
137
|
+
const enableAutoDetect = await ask(' Enable auto-detection of new projects? (Y/n) ');
|
|
138
|
+
const config = {
|
|
139
|
+
...DEFAULT_MEMORY_CONFIG,
|
|
140
|
+
watchedDirs: [projectsDir],
|
|
141
|
+
autoDetectNewProjects: enableAutoDetect.toLowerCase() !== 'n',
|
|
142
|
+
promptForClaudeMd: true,
|
|
143
|
+
lastUpdated: new Date().toISOString(),
|
|
144
|
+
};
|
|
145
|
+
saveMemoryConfig(config);
|
|
146
|
+
if (config.autoDetectNewProjects) {
|
|
147
|
+
console.log(' ✅ Auto-detection enabled');
|
|
148
|
+
console.log(` 📁 Watching: ${projectsDir}`);
|
|
149
|
+
console.log('');
|
|
150
|
+
console.log(' When you start Claude in a new folder under this directory,');
|
|
151
|
+
console.log(' it will offer to generate a CLAUDE.md and add the project to memory.');
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
console.log(' ℹ️ Auto-detection disabled');
|
|
155
|
+
console.log(' You can manually add projects with: claude-memory scan');
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
// Non-interactive: enable with defaults
|
|
160
|
+
const config = {
|
|
161
|
+
...DEFAULT_MEMORY_CONFIG,
|
|
162
|
+
watchedDirs: [projectsDir],
|
|
163
|
+
autoDetectNewProjects: true,
|
|
164
|
+
promptForClaudeMd: true,
|
|
165
|
+
lastUpdated: new Date().toISOString(),
|
|
166
|
+
};
|
|
167
|
+
saveMemoryConfig(config);
|
|
168
|
+
console.log(' ✅ Auto-detection enabled (default)');
|
|
169
|
+
}
|
|
107
170
|
// Done!
|
|
108
171
|
console.log('\n╔══════════════════════════════════════════════════════════╗');
|
|
109
172
|
console.log('║ ✅ Setup Complete! ║');
|
|
@@ -122,6 +185,7 @@ export async function runSetupWizard(options = {}) {
|
|
|
122
185
|
}
|
|
123
186
|
/**
|
|
124
187
|
* Guess the user's projects directory
|
|
188
|
+
* Returns null if we can't find a reasonable guess (better than scanning home!)
|
|
125
189
|
*/
|
|
126
190
|
function guessProjectsDir() {
|
|
127
191
|
const home = homedir();
|
|
@@ -136,14 +200,27 @@ function guessProjectsDir() {
|
|
|
136
200
|
join(home, 'src'),
|
|
137
201
|
join(home, 'repos'),
|
|
138
202
|
join(home, 'git'),
|
|
203
|
+
join(home, 'workspace'),
|
|
204
|
+
join(home, 'Workspace'),
|
|
139
205
|
];
|
|
140
206
|
for (const dir of candidates) {
|
|
141
207
|
if (existsSync(dir)) {
|
|
142
208
|
return dir;
|
|
143
209
|
}
|
|
144
210
|
}
|
|
145
|
-
//
|
|
146
|
-
|
|
211
|
+
// Don't fall back to home - that scans way too much and causes issues
|
|
212
|
+
// Return null and let the caller handle it
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Save memory config to ~/.claude-memory/config.json
|
|
217
|
+
*/
|
|
218
|
+
function saveMemoryConfig(config) {
|
|
219
|
+
// Ensure directory exists
|
|
220
|
+
if (!existsSync(MEMORY_DIR)) {
|
|
221
|
+
mkdirSync(MEMORY_DIR, { recursive: true });
|
|
222
|
+
}
|
|
223
|
+
writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2), 'utf-8');
|
|
147
224
|
}
|
|
148
225
|
/**
|
|
149
226
|
* Configure MCP in ~/.claude.json
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Core types for Claude Memory
|
|
3
3
|
*/
|
|
4
|
+
/** Current schema version - increment when making breaking changes */
|
|
5
|
+
export declare const SCHEMA_VERSION = 1;
|
|
4
6
|
export interface ProjectInfo {
|
|
5
7
|
/** Absolute path to project root */
|
|
6
8
|
path: string;
|
|
@@ -43,14 +45,18 @@ export interface ProjectInsight {
|
|
|
43
45
|
discoveredAt: string;
|
|
44
46
|
}
|
|
45
47
|
export interface GlobalContext {
|
|
48
|
+
/** Schema version for migration support */
|
|
49
|
+
schemaVersion: number;
|
|
46
50
|
/** When the global context was last updated */
|
|
47
51
|
lastUpdated: string;
|
|
48
52
|
/** All scanned projects */
|
|
49
53
|
projects: ProjectInfo[];
|
|
50
|
-
/** Cross-project insights */
|
|
54
|
+
/** Cross-project insights (preserved across rescans) */
|
|
51
55
|
insights: GlobalInsight[];
|
|
52
56
|
/** User preferences/patterns observed */
|
|
53
57
|
userPatterns: UserPattern[];
|
|
58
|
+
/** Projects to exclude from scanning (by path) */
|
|
59
|
+
excludedProjects?: string[];
|
|
54
60
|
}
|
|
55
61
|
export interface GlobalInsight {
|
|
56
62
|
/** Insight content */
|
|
@@ -85,3 +91,32 @@ export interface ScanOptions {
|
|
|
85
91
|
overwriteClaudeMd: boolean;
|
|
86
92
|
}
|
|
87
93
|
export declare const DEFAULT_SCAN_OPTIONS: ScanOptions;
|
|
94
|
+
/**
|
|
95
|
+
* Configuration for claude-memory behavior
|
|
96
|
+
*/
|
|
97
|
+
export interface MemoryConfig {
|
|
98
|
+
/** Directories to watch for new projects */
|
|
99
|
+
watchedDirs: string[];
|
|
100
|
+
/** Whether to auto-detect new projects in watched dirs */
|
|
101
|
+
autoDetectNewProjects: boolean;
|
|
102
|
+
/** Whether to prompt for CLAUDE.md generation on new projects */
|
|
103
|
+
promptForClaudeMd: boolean;
|
|
104
|
+
/** When config was last updated */
|
|
105
|
+
lastUpdated: string;
|
|
106
|
+
}
|
|
107
|
+
export declare const DEFAULT_MEMORY_CONFIG: MemoryConfig;
|
|
108
|
+
/**
|
|
109
|
+
* Status of the current working directory
|
|
110
|
+
*/
|
|
111
|
+
export interface CurrentDirectoryStatus {
|
|
112
|
+
/** The path being checked */
|
|
113
|
+
path: string;
|
|
114
|
+
/** Status of this directory */
|
|
115
|
+
status: 'known_project' | 'new_project' | 'outside_workspace' | 'not_a_project';
|
|
116
|
+
/** Project name if it's a known project */
|
|
117
|
+
projectName?: string;
|
|
118
|
+
/** Whether this directory needs setup */
|
|
119
|
+
needsSetup?: boolean;
|
|
120
|
+
/** Suggested action for Claude to take */
|
|
121
|
+
suggestedAction?: 'none' | 'offer_setup' | 'offer_scan';
|
|
122
|
+
}
|
package/dist/types/index.js
CHANGED
|
@@ -1,10 +1,49 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Core types for Claude Memory
|
|
3
3
|
*/
|
|
4
|
+
/** Current schema version - increment when making breaking changes */
|
|
5
|
+
export const SCHEMA_VERSION = 1;
|
|
6
|
+
/**
|
|
7
|
+
* Get a sensible default projects directory
|
|
8
|
+
* Checks common locations, doesn't fall back to home
|
|
9
|
+
*/
|
|
10
|
+
function getDefaultProjectsDir() {
|
|
11
|
+
const home = process.env.HOME || '';
|
|
12
|
+
if (!home)
|
|
13
|
+
return './projects';
|
|
14
|
+
const candidates = [
|
|
15
|
+
`${home}/Projects`,
|
|
16
|
+
`${home}/Project`,
|
|
17
|
+
`${home}/projects`,
|
|
18
|
+
`${home}/Code`,
|
|
19
|
+
`${home}/code`,
|
|
20
|
+
`${home}/dev`,
|
|
21
|
+
];
|
|
22
|
+
// Import fs dynamically to avoid issues
|
|
23
|
+
try {
|
|
24
|
+
const fs = require('fs');
|
|
25
|
+
for (const dir of candidates) {
|
|
26
|
+
if (fs.existsSync(dir)) {
|
|
27
|
+
return dir;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// fs not available, use first candidate
|
|
33
|
+
}
|
|
34
|
+
// Default to ~/Projects (most common convention)
|
|
35
|
+
return `${home}/Projects`;
|
|
36
|
+
}
|
|
4
37
|
export const DEFAULT_SCAN_OPTIONS = {
|
|
5
|
-
rootDir:
|
|
38
|
+
rootDir: getDefaultProjectsDir(),
|
|
6
39
|
maxDepth: 2,
|
|
7
|
-
ignore: ['node_modules', '.git', 'dist', 'build', '__pycache__', 'target'],
|
|
40
|
+
ignore: ['node_modules', '.git', 'dist', 'build', '__pycache__', 'target', '.venv', 'venv', 'coverage', '.next'],
|
|
8
41
|
generateClaudeMd: false,
|
|
9
42
|
overwriteClaudeMd: false,
|
|
10
43
|
};
|
|
44
|
+
export const DEFAULT_MEMORY_CONFIG = {
|
|
45
|
+
watchedDirs: [],
|
|
46
|
+
autoDetectNewProjects: true,
|
|
47
|
+
promptForClaudeMd: true,
|
|
48
|
+
lastUpdated: new Date().toISOString(),
|
|
49
|
+
};
|