@stackmemoryai/stackmemory 0.5.61 ā 0.5.62
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/scripts/initialize.js +68 -1
- package/dist/scripts/initialize.js.map +2 -2
- package/dist/src/core/retrieval/index.js +2 -0
- package/dist/src/core/retrieval/index.js.map +2 -2
- package/dist/src/core/retrieval/privacy-filter.js +129 -0
- package/dist/src/core/retrieval/privacy-filter.js.map +7 -0
- package/dist/src/core/retrieval/unified-context-assembler.js +273 -0
- package/dist/src/core/retrieval/unified-context-assembler.js.map +7 -0
- package/dist/src/hooks/diffmem-hooks.js +377 -0
- package/dist/src/hooks/diffmem-hooks.js.map +7 -0
- package/dist/src/integrations/diffmem/client.js +209 -0
- package/dist/src/integrations/diffmem/client.js.map +7 -0
- package/dist/src/integrations/diffmem/config.js +15 -0
- package/dist/src/integrations/diffmem/config.js.map +7 -0
- package/dist/src/integrations/diffmem/index.js +12 -0
- package/dist/src/integrations/diffmem/index.js.map +7 -0
- package/dist/src/integrations/diffmem/types.js +5 -0
- package/dist/src/integrations/diffmem/types.js.map +7 -0
- package/dist/src/integrations/mcp/handlers/diffmem-handlers.js +456 -0
- package/dist/src/integrations/mcp/handlers/diffmem-handlers.js.map +7 -0
- package/dist/src/integrations/mcp/server.js +121 -0
- package/dist/src/integrations/mcp/server.js.map +2 -2
- package/package.json +3 -1
- package/scripts/initialize.ts +83 -1
package/scripts/initialize.ts
CHANGED
|
@@ -13,6 +13,9 @@ import {
|
|
|
13
13
|
import { join } from 'path';
|
|
14
14
|
import { execSync } from 'child_process';
|
|
15
15
|
import chalk from 'chalk';
|
|
16
|
+
|
|
17
|
+
// Parse CLI args for --with-diffmem flag
|
|
18
|
+
const enableDiffMem = process.argv.includes('--with-diffmem');
|
|
16
19
|
// Type-safe environment variable access
|
|
17
20
|
function getEnv(key: string, defaultValue?: string): string {
|
|
18
21
|
const value = process.env[key];
|
|
@@ -125,14 +128,93 @@ try {
|
|
|
125
128
|
console.log(chalk.yellow('ā ') + ' Build failed - run npm run build manually');
|
|
126
129
|
}
|
|
127
130
|
|
|
131
|
+
// 7. Optional: Initialize DiffMem for long-term user memory
|
|
132
|
+
if (enableDiffMem) {
|
|
133
|
+
console.log(chalk.blue('\nš§ Setting up DiffMem integration...\n'));
|
|
134
|
+
|
|
135
|
+
const diffmemDir = join(stackDir, 'diffmem');
|
|
136
|
+
const diffmemStorageDir = join(diffmemDir, 'storage');
|
|
137
|
+
const diffmemWorktreesDir = join(diffmemDir, 'worktrees');
|
|
138
|
+
|
|
139
|
+
// Create DiffMem directories
|
|
140
|
+
mkdirSync(diffmemStorageDir, { recursive: true });
|
|
141
|
+
mkdirSync(diffmemWorktreesDir, { recursive: true });
|
|
142
|
+
|
|
143
|
+
// Initialize git repo for storage
|
|
144
|
+
if (!existsSync(join(diffmemStorageDir, '.git'))) {
|
|
145
|
+
try {
|
|
146
|
+
execSync('git init', { cwd: diffmemStorageDir, stdio: 'pipe' });
|
|
147
|
+
execSync('git commit --allow-empty -m "Initialize DiffMem storage"', {
|
|
148
|
+
cwd: diffmemStorageDir,
|
|
149
|
+
stdio: 'pipe',
|
|
150
|
+
});
|
|
151
|
+
console.log(chalk.green('ā') + ' Initialized DiffMem storage repository');
|
|
152
|
+
} catch {
|
|
153
|
+
console.log(
|
|
154
|
+
chalk.yellow('ā ') + ' Failed to initialize git repo for DiffMem'
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Create DiffMem config
|
|
160
|
+
const diffmemConfigPath = join(diffmemDir, 'config.json');
|
|
161
|
+
const diffmemConfig = {
|
|
162
|
+
enabled: true,
|
|
163
|
+
endpoint: 'http://localhost:8000',
|
|
164
|
+
userId: process.env['USER'] || 'default',
|
|
165
|
+
storagePath: diffmemStorageDir,
|
|
166
|
+
worktreePath: diffmemWorktreesDir,
|
|
167
|
+
};
|
|
168
|
+
writeFileSync(diffmemConfigPath, JSON.stringify(diffmemConfig, null, 2));
|
|
169
|
+
console.log(chalk.green('ā') + ' Created DiffMem configuration');
|
|
170
|
+
|
|
171
|
+
// Add DiffMem env vars to .env file
|
|
172
|
+
const envPath = join(projectRoot, '.env');
|
|
173
|
+
const diffmemEnvVars = `
|
|
174
|
+
# DiffMem Configuration (Long-term User Memory)
|
|
175
|
+
DIFFMEM_ENABLED=true
|
|
176
|
+
DIFFMEM_ENDPOINT=http://localhost:8000
|
|
177
|
+
DIFFMEM_USER_ID=${process.env['USER'] || 'default'}
|
|
178
|
+
DIFFMEM_STORAGE_PATH=${diffmemStorageDir}
|
|
179
|
+
DIFFMEM_WORKTREE_PATH=${diffmemWorktreesDir}
|
|
180
|
+
`;
|
|
181
|
+
|
|
182
|
+
if (existsSync(envPath)) {
|
|
183
|
+
const envContent = readFileSync(envPath, 'utf-8');
|
|
184
|
+
if (!envContent.includes('DIFFMEM_')) {
|
|
185
|
+
appendFileSync(envPath, diffmemEnvVars);
|
|
186
|
+
console.log(chalk.green('ā') + ' Added DiffMem configuration to .env');
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
writeFileSync(envPath, diffmemEnvVars.trim() + '\n');
|
|
190
|
+
console.log(chalk.green('ā') + ' Created .env with DiffMem configuration');
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
console.log(chalk.green('ā') + ' DiffMem integration configured');
|
|
194
|
+
console.log(
|
|
195
|
+
chalk.gray(
|
|
196
|
+
' Note: DiffMem server must be running for user memory features'
|
|
197
|
+
)
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
|
|
128
201
|
console.log(chalk.green.bold('\nā
StackMemory initialized successfully!\n'));
|
|
129
202
|
console.log(chalk.gray('Next steps:'));
|
|
130
203
|
console.log(chalk.gray('1. Add the MCP configuration above to Claude Code'));
|
|
131
204
|
console.log(chalk.gray('2. Restart Claude Code'));
|
|
132
205
|
console.log(chalk.gray('3. Start using context tracking!'));
|
|
206
|
+
if (enableDiffMem) {
|
|
207
|
+
console.log(chalk.gray('4. Start DiffMem server: npm run diffmem:start'));
|
|
208
|
+
}
|
|
133
209
|
console.log(chalk.gray('\nUseful commands:'));
|
|
134
210
|
console.log(
|
|
135
211
|
chalk.cyan(' npm run mcp:dev') + ' - Start MCP server in dev mode'
|
|
136
212
|
);
|
|
137
213
|
console.log(chalk.cyan(' npm run status') + ' - Check StackMemory status');
|
|
138
|
-
console.log(chalk.cyan(' npm run analyze') + ' - Analyze context usage
|
|
214
|
+
console.log(chalk.cyan(' npm run analyze') + ' - Analyze context usage');
|
|
215
|
+
if (enableDiffMem) {
|
|
216
|
+
console.log(
|
|
217
|
+
chalk.cyan(' npm run diffmem:start') + ' - Start DiffMem server'
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
console.log();
|