mindkeg-mcp 0.7.0 → 0.7.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/dist/cli/index.js +48 -60
- package/dist/cli/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -7055,7 +7055,7 @@ function registerImportCommand(program2) {
|
|
|
7055
7055
|
}
|
|
7056
7056
|
|
|
7057
7057
|
// cli/commands/init.ts
|
|
7058
|
-
import { existsSync, mkdirSync as mkdirSync3, readFileSync as readFileSync2, writeFileSync as writeFileSync2, copyFileSync } from "fs";
|
|
7058
|
+
import { existsSync, mkdirSync as mkdirSync3, readFileSync as readFileSync2, writeFileSync as writeFileSync2, copyFileSync, readdirSync } from "fs";
|
|
7059
7059
|
import { resolve, join as join2, dirname as dirname3 } from "path";
|
|
7060
7060
|
import { execSync } from "child_process";
|
|
7061
7061
|
import { fileURLToPath } from "url";
|
|
@@ -7071,7 +7071,7 @@ function generateBashHook() {
|
|
|
7071
7071
|
REPO_PATH=$(git rev-parse --show-toplevel 2>/dev/null || echo "$PWD")
|
|
7072
7072
|
export MINDKEG_REPO="$REPO_PATH"
|
|
7073
7073
|
|
|
7074
|
-
node --experimental-sqlite -e "
|
|
7074
|
+
OUTPUT=$(node --experimental-sqlite -e "
|
|
7075
7075
|
(async () => {
|
|
7076
7076
|
try {
|
|
7077
7077
|
const os = await import('node:os');
|
|
@@ -7092,63 +7092,21 @@ node --experimental-sqlite -e "
|
|
|
7092
7092
|
|
|
7093
7093
|
if (rows.length === 0) process.exit(0);
|
|
7094
7094
|
|
|
7095
|
-
const lines = ['
|
|
7095
|
+
const lines = ['Mind Keg Persistent Memory (from ~/.mindkeg/brain.db):', ''];
|
|
7096
7096
|
for (const row of rows) {
|
|
7097
7097
|
lines.push('- [' + row.category + '] ' + row.content);
|
|
7098
7098
|
}
|
|
7099
|
-
lines.push('', 'Use get_context for
|
|
7099
|
+
lines.push('', 'These learnings were loaded from Mind Keg. Use get_context for more details or store to save new knowledge.');
|
|
7100
7100
|
console.log(lines.join('\\n'));
|
|
7101
7101
|
} catch (e) {
|
|
7102
7102
|
// Silent failure \u2014 never block session startup
|
|
7103
7103
|
}
|
|
7104
7104
|
})();
|
|
7105
|
-
" 2>/dev/null
|
|
7105
|
+
" 2>/dev/null)
|
|
7106
7106
|
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
|
|
7110
|
-
function generatePowerShellHook() {
|
|
7111
|
-
return `# Mind Keg \u2014 SessionStart auto-retrieval hook
|
|
7112
|
-
# Generated by: npx mindkeg-mcp init
|
|
7113
|
-
# Loads persistent memory at the start of every Claude Code session.
|
|
7114
|
-
|
|
7115
|
-
try {
|
|
7116
|
-
$repoPath = git rev-parse --show-toplevel 2>$null
|
|
7117
|
-
if (-not $repoPath) { $repoPath = $PWD.Path }
|
|
7118
|
-
$env:MINDKEG_REPO = $repoPath
|
|
7119
|
-
|
|
7120
|
-
node --experimental-sqlite -e "
|
|
7121
|
-
(async () => {
|
|
7122
|
-
try {
|
|
7123
|
-
const os = await import('node:os');
|
|
7124
|
-
const path = await import('node:path');
|
|
7125
|
-
const { DatabaseSync } = await import('node:sqlite');
|
|
7126
|
-
|
|
7127
|
-
const dbPath = path.join(os.homedir(), '.mindkeg', 'brain.db');
|
|
7128
|
-
const db = new DatabaseSync(dbPath, { open: true, readOnly: true });
|
|
7129
|
-
|
|
7130
|
-
const repo = process.env.MINDKEG_REPO || '';
|
|
7131
|
-
const workspace = path.dirname(repo) + '/';
|
|
7132
|
-
|
|
7133
|
-
const stmt = db.prepare(
|
|
7134
|
-
'SELECT content, category FROM learnings WHERE status = ? AND (repository = ? OR workspace = ? OR (repository IS NULL AND workspace IS NULL)) ORDER BY updated_at DESC LIMIT 20'
|
|
7135
|
-
);
|
|
7136
|
-
const rows = stmt.all('active', repo, workspace);
|
|
7137
|
-
|
|
7138
|
-
if (rows.length === 0) process.exit(0);
|
|
7139
|
-
|
|
7140
|
-
const lines = ['=== Mind Keg: Persistent Memory ===', ''];
|
|
7141
|
-
for (const row of rows) {
|
|
7142
|
-
lines.push('- [' + row.category + '] ' + row.content);
|
|
7143
|
-
}
|
|
7144
|
-
lines.push('', 'Use get_context for full details or store to save new knowledge.');
|
|
7145
|
-
console.log(lines.join('\\n'));
|
|
7146
|
-
} catch (e) {}
|
|
7147
|
-
})();
|
|
7148
|
-
" 2>$null
|
|
7149
|
-
} catch {
|
|
7150
|
-
# Silent failure
|
|
7151
|
-
}
|
|
7107
|
+
if [ -n "$OUTPUT" ]; then
|
|
7108
|
+
echo "$OUTPUT"
|
|
7109
|
+
fi
|
|
7152
7110
|
|
|
7153
7111
|
exit 0
|
|
7154
7112
|
`;
|
|
@@ -7297,25 +7255,37 @@ function writeGlobalMcpConfig(homeDir, agent) {
|
|
|
7297
7255
|
writeFileSync2(configPath, JSON.stringify(existing, null, 2) + "\n", "utf-8");
|
|
7298
7256
|
return { created: true, path: configPath };
|
|
7299
7257
|
}
|
|
7300
|
-
function
|
|
7301
|
-
const
|
|
7302
|
-
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
|
|
7258
|
+
function detectClaudeProfiles(homeDir) {
|
|
7259
|
+
const profiles = [];
|
|
7260
|
+
try {
|
|
7261
|
+
const entries = readdirSync(homeDir, { withFileTypes: true });
|
|
7262
|
+
for (const entry of entries) {
|
|
7263
|
+
if (entry.isDirectory() && entry.name.startsWith(".claude-") && entry.name !== ".claude-worktrees") {
|
|
7264
|
+
const settingsPath = join2(homeDir, entry.name, "settings.json");
|
|
7265
|
+
if (existsSync(settingsPath)) {
|
|
7266
|
+
profiles.push(entry.name);
|
|
7267
|
+
}
|
|
7268
|
+
}
|
|
7269
|
+
}
|
|
7270
|
+
} catch {
|
|
7271
|
+
}
|
|
7272
|
+
return profiles;
|
|
7273
|
+
}
|
|
7274
|
+
function writeHookToDir(hookDir, settingsPath) {
|
|
7275
|
+
const hookFileName = "load-mindkeg.sh";
|
|
7306
7276
|
const hookPath = join2(hookDir, hookFileName);
|
|
7307
7277
|
if (!existsSync(hookDir)) {
|
|
7308
7278
|
mkdirSync3(hookDir, { recursive: true });
|
|
7309
7279
|
}
|
|
7310
|
-
const scriptContent =
|
|
7280
|
+
const scriptContent = generateBashHook();
|
|
7311
7281
|
writeFileSync2(hookPath, scriptContent, "utf-8");
|
|
7312
|
-
if (
|
|
7282
|
+
if (process.platform !== "win32") {
|
|
7313
7283
|
try {
|
|
7314
7284
|
execSync(`chmod +x "${hookPath}"`, { stdio: ["pipe", "pipe", "pipe"] });
|
|
7315
7285
|
} catch {
|
|
7316
7286
|
}
|
|
7317
7287
|
}
|
|
7318
|
-
const
|
|
7288
|
+
const hookCommand = "bash " + hookPath.replace(/\\/g, "/");
|
|
7319
7289
|
let settings = {};
|
|
7320
7290
|
if (existsSync(settingsPath)) {
|
|
7321
7291
|
try {
|
|
@@ -7323,7 +7293,7 @@ function writeGlobalHook(homeDir, agent) {
|
|
|
7323
7293
|
} catch {
|
|
7324
7294
|
}
|
|
7325
7295
|
}
|
|
7326
|
-
const hookConfig = generateHookConfig(
|
|
7296
|
+
const hookConfig = generateHookConfig(hookCommand);
|
|
7327
7297
|
const existingHooks = settings["hooks"] ?? {};
|
|
7328
7298
|
const newHooks = hookConfig["hooks"] ?? {};
|
|
7329
7299
|
const existingSessionStart = existingHooks["SessionStart"] ?? [];
|
|
@@ -7340,6 +7310,13 @@ function writeGlobalHook(homeDir, agent) {
|
|
|
7340
7310
|
}
|
|
7341
7311
|
return { created: !alreadyHasMindkeg, path: hookPath };
|
|
7342
7312
|
}
|
|
7313
|
+
function writeGlobalHook(homeDir, agent) {
|
|
7314
|
+
const config = AGENT_CONFIGS[agent];
|
|
7315
|
+
if (!config.globalHookDir || !config.globalSettingsFile) return null;
|
|
7316
|
+
const hookDir = join2(homeDir, config.globalHookDir);
|
|
7317
|
+
const settingsPath = join2(homeDir, config.globalSettingsFile);
|
|
7318
|
+
return writeHookToDir(hookDir, settingsPath);
|
|
7319
|
+
}
|
|
7343
7320
|
function ensureDatabase(homeDir) {
|
|
7344
7321
|
const dbDir = join2(homeDir, ".mindkeg");
|
|
7345
7322
|
const dbPath = join2(dbDir, "brain.db");
|
|
@@ -7445,6 +7422,17 @@ Mind Keg \u2014 Global Setup for ${AGENT_CONFIGS[agent].label}
|
|
|
7445
7422
|
} else {
|
|
7446
7423
|
console.log(` - Hook already registered`);
|
|
7447
7424
|
}
|
|
7425
|
+
const profiles = detectClaudeProfiles(home);
|
|
7426
|
+
for (const profile of profiles) {
|
|
7427
|
+
const profileHookDir = join2(home, profile, "hooks");
|
|
7428
|
+
const profileSettingsFile = join2(home, profile, "settings.json");
|
|
7429
|
+
const profileResult = writeHookToDir(profileHookDir, profileSettingsFile);
|
|
7430
|
+
if (profileResult.created) {
|
|
7431
|
+
console.log(` \u2713 Wrote ${profileResult.path} (profile: ${profile})`);
|
|
7432
|
+
} else {
|
|
7433
|
+
console.log(` - Hook already registered in ${profile}`);
|
|
7434
|
+
}
|
|
7435
|
+
}
|
|
7448
7436
|
}
|
|
7449
7437
|
console.log("\nDatabase:");
|
|
7450
7438
|
const dbResult = ensureDatabase(home);
|