claude-launchpad 0.7.0 → 0.7.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 +7 -3
- package/dist/cli.js.map +1 -1
- package/dist/{install-65P6LMUN.js → install-EQEBGXQE.js} +3 -1
- package/dist/install-EQEBGXQE.js.map +1 -0
- package/dist/require-deps-EHWR6TVD.js +29 -0
- package/dist/require-deps-EHWR6TVD.js.map +1 -0
- package/dist/{stats-FYAK7KZW.js → stats-ZKET3Q4E.js} +3 -1
- package/dist/stats-ZKET3Q4E.js.map +1 -0
- package/package.json +5 -5
- package/dist/install-65P6LMUN.js.map +0 -1
- package/dist/stats-FYAK7KZW.js.map +0 -1
|
@@ -20,6 +20,8 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
|
20
20
|
import { join } from "path";
|
|
21
21
|
import { execSync } from "child_process";
|
|
22
22
|
async function runInstall(opts) {
|
|
23
|
+
const { requireMemoryDeps } = await import("./require-deps-EHWR6TVD.js");
|
|
24
|
+
await requireMemoryDeps();
|
|
23
25
|
log.blank();
|
|
24
26
|
log.step("Memory system - install");
|
|
25
27
|
log.blank();
|
|
@@ -227,4 +229,4 @@ function installSkills(projectDir) {
|
|
|
227
229
|
export {
|
|
228
230
|
runInstall
|
|
229
231
|
};
|
|
230
|
-
//# sourceMappingURL=install-
|
|
232
|
+
//# sourceMappingURL=install-EQEBGXQE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/memory/subcommands/install.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { execSync } from 'node:child_process';\nimport { createDatabase, closeDatabase } from '../storage/database.js';\nimport { migrate } from '../storage/migrator.js';\nimport { loadConfig, resolveDataDir } from '../config.js';\nimport { readSettingsJson, writeSettingsJson } from '../../../lib/settings.js';\nimport { log } from '../../../lib/output.js';\n\ninterface InstallOpts {\n readonly dbPath?: string;\n}\n\nexport async function runInstall(opts: InstallOpts): Promise<void> {\n const { requireMemoryDeps } = await import('../utils/require-deps.js');\n await requireMemoryDeps();\n\n log.blank();\n log.step('Memory system - install');\n log.blank();\n\n const config = loadConfig(opts.dbPath ? { dataDir: opts.dbPath } : undefined);\n const dataDir = resolveDataDir(config.dataDir);\n\n // Step 1: Database\n log.step('[1/4] Setting up database...');\n if (!existsSync(dataDir)) {\n mkdirSync(dataDir, { recursive: true });\n }\n const db = createDatabase({ dataDir });\n migrate(db);\n closeDatabase(db);\n log.success(`${dataDir}/memory.db ready`);\n\n // Step 2: Configure Claude Code settings\n log.step('[2/4] Configuring Claude Code...');\n await configureSettings(process.cwd());\n\n // Step 3: Register MCP server\n log.step('[3/4] Registering MCP server...');\n const registered = registerMcpServer();\n if (registered) {\n log.success('MCP server registered via `claude mcp add`');\n } else {\n log.warn('Could not register MCP server automatically.');\n log.info('Run: claude mcp add agentic-memory -- npx claude-launchpad memory serve');\n }\n\n // Step 4: CLAUDE.md + skills\n log.step('[4/4] Injecting guidance...');\n const guidanceAdded = injectClaudeMdGuidance(process.cwd());\n if (guidanceAdded) {\n log.success('Memory guidance added to CLAUDE.md');\n }\n const skillsInstalled = installSkills(process.cwd());\n if (skillsInstalled > 0) {\n log.success(`Installed ${skillsInstalled} skill(s) to .claude/skills/`);\n }\n\n log.blank();\n log.success('Memory system installed.');\n log.info('Restart your Claude Code session for the MCP server to connect.');\n log.blank();\n}\n\nasync function configureSettings(projectDir: string): Promise<void> {\n const settings = await readSettingsJson(projectDir);\n\n // Disable built-in auto-memory\n settings['autoMemoryEnabled'] = false;\n log.info('Built-in auto-memory disabled');\n\n // SessionStart hook\n const hooks = (settings['hooks'] ?? {}) as Record<string, unknown[]>;\n addSessionStartHook(hooks);\n addStopHook(hooks);\n settings['hooks'] = hooks;\n\n // Auto-allow MCP tools\n addToolPermissions(settings);\n\n await writeSettingsJson(projectDir, settings);\n log.success('settings.json updated');\n}\n\nfunction addSessionStartHook(hooks: Record<string, unknown[]>): void {\n const sessionStartHooks = (hooks['SessionStart'] ?? []) as Record<string, unknown>[];\n const hookCommand = 'npx claude-launchpad memory context --json 2>/dev/null; exit 0';\n\n const alreadyHooked = sessionStartHooks.some((h) => {\n const innerHooks = h['hooks'] as Record<string, unknown>[] | undefined;\n return innerHooks?.some(\n ih => typeof ih['command'] === 'string' && (ih['command'] as string).includes('claude-launchpad memory context'),\n );\n });\n\n if (!alreadyHooked) {\n sessionStartHooks.push({\n matcher: 'startup|resume',\n hooks: [{ type: 'command', command: hookCommand }],\n });\n hooks['SessionStart'] = sessionStartHooks;\n log.info('SessionStart hook added (injects memory context)');\n }\n}\n\nfunction addStopHook(hooks: Record<string, unknown[]>): void {\n const stopHooks = (hooks['Stop'] ?? []) as Record<string, unknown>[];\n const extractCommand = 'npx claude-launchpad memory extract 2>/dev/null; exit 0';\n\n const alreadyHasExtract = stopHooks.some((h) => {\n const innerHooks = h['hooks'] as Record<string, unknown>[] | undefined;\n return innerHooks?.some(\n ih => typeof ih['command'] === 'string' && (ih['command'] as string).includes('claude-launchpad memory extract'),\n );\n });\n\n if (!alreadyHasExtract) {\n stopHooks.push({\n hooks: [{ type: 'command', command: extractCommand, async: true }],\n });\n hooks['Stop'] = stopHooks;\n log.info('Stop hook added (extracts facts from transcript)');\n }\n}\n\nfunction addToolPermissions(settings: Record<string, unknown>): void {\n const permissions = (settings['permissions'] ?? {}) as Record<string, unknown>;\n const allowList = (permissions['allow'] ?? []) as string[];\n\n const memoryTools = [\n 'mcp__agentic-memory__memory_store',\n 'mcp__agentic-memory__memory_search',\n 'mcp__agentic-memory__memory_recent',\n 'mcp__agentic-memory__memory_forget',\n 'mcp__agentic-memory__memory_relate',\n 'mcp__agentic-memory__memory_stats',\n 'mcp__agentic-memory__memory_update',\n ];\n\n let added = 0;\n for (const tool of memoryTools) {\n if (!allowList.includes(tool)) {\n allowList.push(tool);\n added++;\n }\n }\n\n if (added > 0) {\n permissions['allow'] = allowList;\n settings['permissions'] = permissions;\n log.info(`Auto-allowed ${added} MCP tools`);\n }\n}\n\nfunction registerMcpServer(): boolean {\n try {\n execSync(\n 'claude mcp add --scope user agentic-memory -- npx claude-launchpad memory serve',\n { stdio: 'pipe', timeout: 10000 },\n );\n return true;\n } catch {\n return false;\n }\n}\n\nconst MEMORY_GUIDANCE = `\n## Memory (agentic-memory)\nThis project uses **agentic-memory** for persistent memory across sessions.\n- **DO NOT** use the built-in auto-memory system (~/.claude/projects/*/memory/)\n- Memory context is **automatically injected** at session start via SessionStart hook - no need to call memory_recent manually\n- Use \\`memory_search\\` to find specific memories by keyword\n- Use \\`memory_store\\` to save decisions, gotchas, and learnings worth remembering\n- Use \\`memory_stats\\` to check memory health\n`;\n\nfunction injectClaudeMdGuidance(projectDir: string): boolean {\n const claudeMdPath = join(projectDir, 'CLAUDE.md');\n\n let content = '';\n try {\n content = readFileSync(claudeMdPath, 'utf-8');\n } catch {\n return false;\n }\n\n if (content.includes('## Memory (agentic-memory)')) {\n return false;\n }\n\n const updated = content.trimEnd() + '\\n' + MEMORY_GUIDANCE;\n writeFileSync(claudeMdPath, updated, 'utf-8');\n return true;\n}\n\nconst MIGRATE_MEMORY_SKILL = `---\nname: lp-migrate-memory\ndescription: Migrate legacy Claude Code auto-memory files (~/.claude/projects/*/memory/*.md) into agentic-memory. Use when setting up agentic-memory on a project that already has built-in memories.\nallowed-tools: Read, Glob, Grep, mcp__agentic-memory__memory_store, mcp__agentic-memory__memory_search\n---\n\n# Migrate Legacy Claude Code Memories\n\nMigrate memory files from Claude Code's built-in auto-memory system into agentic-memory.\n\n## Steps\n\n1. **Find legacy memory files** for this project:\n - Scan \\`~/.claude/projects/*/memory/*.md\\` for directories whose slug matches the current project path\n - The slug format is the absolute path with \\`/\\` replaced by \\`-\\` and leading \\`-\\` (e.g. \\`-Users-john-projects-myapp\\`)\n - Also check \\`~/.claude/projects/*/memory/team/*.md\\` for team memories\n\n2. **For each memory file found**, read it and parse:\n - YAML frontmatter: \\`name\\`, \\`description\\`, \\`type\\` (user/feedback/project/reference)\n - Body content (everything after the frontmatter closing \\`---\\`)\n - Skip \\`MEMORY.md\\` (it's just an index file, not a memory)\n\n3. **Before storing**, check for duplicates:\n - Call \\`memory_search\\` with the memory description or first 100 chars of content\n - If a close match exists (same topic), skip it and report\n\n4. **Map types and store** each memory via \\`memory_store\\`:\n - \\`user\\` -> type: \\`semantic\\`, tags: [\\`user\\`, \\`migrated\\`], importance: 0.7\n - \\`feedback\\` -> type: \\`semantic\\`, tags: [\\`feedback\\`, \\`migrated\\`], importance: 0.8\n - \\`project\\` -> type: \\`semantic\\`, tags: [\\`project\\`, \\`migrated\\`], importance: 0.6\n - \\`reference\\` -> type: \\`semantic\\`, tags: [\\`reference\\`, \\`migrated\\`], importance: 0.5\n - Use the frontmatter \\`name\\` as the title\n - Use the body content as the memory content\n - Set source: \\`import\\`\n - Adjust importance up/down based on the content (decisions and gotchas deserve higher importance)\n\n5. **Report results**: list what was migrated, what was skipped (duplicates), and what failed\n\n## Important\n\n- Do NOT delete the original files - the user can do that manually after verifying\n- Do NOT migrate content that is purely derived from code (architecture, file structure) - it belongs in CLAUDE.md, not memory\n- If unsure about a memory's value, migrate it anyway - the decay system will naturally prune low-value memories over time\n`;\n\nconst SKILLS: Readonly<Record<string, string>> = {\n 'lp-migrate-memory': MIGRATE_MEMORY_SKILL,\n};\n\nfunction installSkills(projectDir: string): number {\n const skillsDir = join(projectDir, '.claude', 'skills');\n let installed = 0;\n\n for (const [name, content] of Object.entries(SKILLS)) {\n const skillDir = join(skillsDir, name);\n const skillPath = join(skillDir, 'SKILL.md');\n\n if (existsSync(skillPath)) continue;\n\n mkdirSync(skillDir, { recursive: true });\n writeFileSync(skillPath, content.trimStart(), 'utf-8');\n installed++;\n }\n\n return installed;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,WAAW,cAAc,qBAAqB;AACnE,SAAS,YAAY;AACrB,SAAS,gBAA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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6C7B,IAAM,SAA2C;AAAA,EAC/C,qBAAqB;AACvB;AAEA,SAAS,cAAc,YAA4B;AACjD,QAAM,YAAY,KAAK,YAAY,WAAW,QAAQ;AACtD,MAAI,YAAY;AAEhB,aAAW,CAAC,MAAM,OAAO,KAAK,OAAO,QAAQ,MAAM,GAAG;AACpD,UAAM,WAAW,KAAK,WAAW,IAAI;AACrC,UAAM,YAAY,KAAK,UAAU,UAAU;AAE3C,QAAI,WAAW,SAAS,EAAG;AAE3B,cAAU,UAAU,EAAE,WAAW,KAAK,CAAC;AACvC,kBAAc,WAAW,QAAQ,UAAU,GAAG,OAAO;AACrD;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
log
|
|
4
|
+
} from "./chunk-6ZVXZ4EF.js";
|
|
5
|
+
import "./chunk-2H7UOFLK.js";
|
|
6
|
+
|
|
7
|
+
// src/commands/memory/utils/require-deps.ts
|
|
8
|
+
async function requireMemoryDeps() {
|
|
9
|
+
try {
|
|
10
|
+
await import("better-sqlite3");
|
|
11
|
+
return true;
|
|
12
|
+
} catch {
|
|
13
|
+
log.blank();
|
|
14
|
+
log.error("Memory system requires native dependencies that are not installed.");
|
|
15
|
+
log.blank();
|
|
16
|
+
log.info("Run this to install them:");
|
|
17
|
+
log.blank();
|
|
18
|
+
log.step(" npm install better-sqlite3 sqlite-vec");
|
|
19
|
+
log.blank();
|
|
20
|
+
log.info("This requires a C++ compiler (Xcode on macOS, build-essential on Linux).");
|
|
21
|
+
log.info("After installing, run `claude-launchpad memory` again.");
|
|
22
|
+
log.blank();
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
requireMemoryDeps
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=require-deps-EHWR6TVD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/memory/utils/require-deps.ts"],"sourcesContent":["import { log } from \"../../../lib/output.js\";\n\n/**\n * Check if memory native dependencies are available.\n * Called at the start of any subcommand that needs SQLite.\n * Returns true if deps are available, exits with helpful message if not.\n */\nexport async function requireMemoryDeps(): Promise<boolean> {\n try {\n await import(\"better-sqlite3\");\n return true;\n } catch {\n log.blank();\n log.error(\"Memory system requires native dependencies that are not installed.\");\n log.blank();\n log.info(\"Run this to install them:\");\n log.blank();\n log.step(\" npm install better-sqlite3 sqlite-vec\");\n log.blank();\n log.info(\"This requires a C++ compiler (Xcode on macOS, build-essential on Linux).\");\n log.info(\"After installing, run `claude-launchpad memory` again.\");\n log.blank();\n process.exit(1);\n }\n}\n"],"mappings":";;;;;;;AAOA,eAAsB,oBAAsC;AAC1D,MAAI;AACF,UAAM,OAAO,gBAAgB;AAC7B,WAAO;AAAA,EACT,QAAQ;AACN,QAAI,MAAM;AACV,QAAI,MAAM,oEAAoE;AAC9E,QAAI,MAAM;AACV,QAAI,KAAK,2BAA2B;AACpC,QAAI,MAAM;AACV,QAAI,KAAK,yCAAyC;AAClD,QAAI,MAAM;AACV,QAAI,KAAK,0EAA0E;AACnF,QAAI,KAAK,wDAAwD;AACjE,QAAI,MAAM;AACV,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;","names":[]}
|
|
@@ -18,6 +18,8 @@ function formatBytes(bytes) {
|
|
|
18
18
|
return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;
|
|
19
19
|
}
|
|
20
20
|
async function runStats(opts) {
|
|
21
|
+
const { requireMemoryDeps } = await import("./require-deps-EHWR6TVD.js");
|
|
22
|
+
await requireMemoryDeps();
|
|
21
23
|
const ctx = initStorage(opts.dbPath);
|
|
22
24
|
try {
|
|
23
25
|
const total = ctx.memoryRepo.count();
|
|
@@ -70,4 +72,4 @@ async function runStats(opts) {
|
|
|
70
72
|
export {
|
|
71
73
|
runStats
|
|
72
74
|
};
|
|
73
|
-
//# sourceMappingURL=stats-
|
|
75
|
+
//# sourceMappingURL=stats-ZKET3Q4E.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/memory/subcommands/stats.ts"],"sourcesContent":["import { existsSync, statSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { log } from '../../../lib/output.js';\nimport { initStorage } from './init-storage.js';\n\ninterface StatsOpts {\n readonly json?: boolean;\n readonly dbPath?: string;\n}\n\nfunction formatBytes(bytes: number): string {\n if (bytes < 1024) return `${bytes}B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)}KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;\n}\n\nexport async function runStats(opts: StatsOpts): Promise<void> {\n const { requireMemoryDeps } = await import('../utils/require-deps.js');\n await requireMemoryDeps();\n const ctx = initStorage(opts.dbPath);\n\n try {\n const total = ctx.memoryRepo.count();\n const byType = ctx.memoryRepo.countByType();\n const relations = ctx.relationRepo.count();\n const dateRange = ctx.memoryRepo.dateRange();\n const topInjected = ctx.memoryRepo.topInjected(5);\n\n let dbSize = 0;\n try {\n const dbPath = join(ctx.dataDir, 'memory.db');\n if (existsSync(dbPath)) {\n dbSize = statSync(dbPath).size;\n }\n } catch { /* ignore */ }\n\n if (opts.json) {\n process.stdout.write(JSON.stringify({\n totalMemories: total,\n byType,\n totalRelations: relations,\n dbSizeBytes: dbSize,\n oldestMemory: dateRange.oldest,\n newestMemory: dateRange.newest,\n topInjected,\n }, null, 2) + '\\n');\n } else {\n log.blank();\n log.step('Memory stats');\n log.info(`Memories: ${total}`);\n for (const [type, count] of Object.entries(byType)) {\n log.info(` ${type}: ${count}`);\n }\n log.info(`Relations: ${relations}`);\n log.info(`DB size: ${formatBytes(dbSize)}`);\n log.info(`Oldest: ${dateRange.oldest ?? 'none'}`);\n log.info(`Newest: ${dateRange.newest ?? 'none'}`);\n if (topInjected.length > 0) {\n log.blank();\n log.info('Top injected:');\n for (const m of topInjected) {\n log.info(` ${m.title ?? m.id} (${m.injectionCount}x)`);\n }\n }\n log.blank();\n }\n } finally {\n ctx.close();\n }\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,YAAY,gBAAgB;AACrC,SAAS,YAAY;AASrB,SAAS,YAAY,OAAuB;AAC1C,MAAI,QAAQ,KAAM,QAAO,GAAG,KAAK;AACjC,MAAI,QAAQ,OAAO,KAAM,QAAO,IAAI,QAAQ,MAAM,QAAQ,CAAC,CAAC;AAC5D,SAAO,IAAI,SAAS,OAAO,OAAO,QAAQ,CAAC,CAAC;AAC9C;AAEA,eAAsB,SAAS,MAAgC;AAC7D,QAAM,EAAE,kBAAkB,IAAI,MAAM,OAAO,4BAA0B;AACrE,QAAM,kBAAkB;AACxB,QAAM,MAAM,YAAY,KAAK,MAAM;AAEnC,MAAI;AACF,UAAM,QAAQ,IAAI,WAAW,MAAM;AACnC,UAAM,SAAS,IAAI,WAAW,YAAY;AAC1C,UAAM,YAAY,IAAI,aAAa,MAAM;AACzC,UAAM,YAAY,IAAI,WAAW,UAAU;AAC3C,UAAM,cAAc,IAAI,WAAW,YAAY,CAAC;AAEhD,QAAI,SAAS;AACb,QAAI;AACF,YAAM,SAAS,KAAK,IAAI,SAAS,WAAW;AAC5C,UAAI,WAAW,MAAM,GAAG;AACtB,iBAAS,SAAS,MAAM,EAAE;AAAA,MAC5B;AAAA,IACF,QAAQ;AAAA,IAAe;AAEvB,QAAI,KAAK,MAAM;AACb,cAAQ,OAAO,MAAM,KAAK,UAAU;AAAA,QAClC,eAAe;AAAA,QACf;AAAA,QACA,gBAAgB;AAAA,QAChB,aAAa;AAAA,QACb,cAAc,UAAU;AAAA,QACxB,cAAc,UAAU;AAAA,QACxB;AAAA,MACF,GAAG,MAAM,CAAC,IAAI,IAAI;AAAA,IACpB,OAAO;AACL,UAAI,MAAM;AACV,UAAI,KAAK,cAAc;AACvB,UAAI,KAAK,eAAe,KAAK,EAAE;AAC/B,iBAAW,CAAC,MAAM,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AAClD,YAAI,KAAK,KAAK,IAAI,KAAK,KAAK,EAAE;AAAA,MAChC;AACA,UAAI,KAAK,eAAe,SAAS,EAAE;AACnC,UAAI,KAAK,eAAe,YAAY,MAAM,CAAC,EAAE;AAC7C,UAAI,KAAK,eAAe,UAAU,UAAU,MAAM,EAAE;AACpD,UAAI,KAAK,eAAe,UAAU,UAAU,MAAM,EAAE;AACpD,UAAI,YAAY,SAAS,GAAG;AAC1B,YAAI,MAAM;AACV,YAAI,KAAK,eAAe;AACxB,mBAAW,KAAK,aAAa;AAC3B,cAAI,KAAK,KAAK,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,cAAc,IAAI;AAAA,QACxD;AAAA,MACF;AACA,UAAI,MAAM;AAAA,IACZ;AAAA,EACF,UAAE;AACA,QAAI,MAAM;AAAA,EACZ;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-launchpad",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "CLI toolkit that makes Claude Code setups measurably good - scaffold, diagnose, evaluate, remember",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -56,16 +56,16 @@
|
|
|
56
56
|
},
|
|
57
57
|
"optionalDependencies": {
|
|
58
58
|
"@anthropic-ai/claude-agent-sdk": "^0.2.86",
|
|
59
|
-
"better-sqlite3": "^11.8.0",
|
|
60
|
-
"blessed": "^0.1.81",
|
|
61
|
-
"sqlite-vec": "^0.1.6",
|
|
62
59
|
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
63
|
-
"zod": "^
|
|
60
|
+
"zod": "^4.0.0"
|
|
64
61
|
},
|
|
65
62
|
"devDependencies": {
|
|
66
63
|
"@types/blessed": "^0.1.25",
|
|
67
64
|
"@types/better-sqlite3": "^7.6.12",
|
|
68
65
|
"@types/node": "^25.5.0",
|
|
66
|
+
"better-sqlite3": "^11.8.0",
|
|
67
|
+
"blessed": "^0.1.81",
|
|
68
|
+
"sqlite-vec": "^0.1.6",
|
|
69
69
|
"tsup": "^8.5.1",
|
|
70
70
|
"tsx": "^4.21.0",
|
|
71
71
|
"typescript": "^6.0.2",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/memory/subcommands/install.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { execSync } from 'node:child_process';\nimport { createDatabase, closeDatabase } from '../storage/database.js';\nimport { migrate } from '../storage/migrator.js';\nimport { loadConfig, resolveDataDir } from '../config.js';\nimport { readSettingsJson, writeSettingsJson } from '../../../lib/settings.js';\nimport { log } from '../../../lib/output.js';\n\ninterface InstallOpts {\n readonly dbPath?: string;\n}\n\nexport async function runInstall(opts: InstallOpts): Promise<void> {\n log.blank();\n log.step('Memory system - install');\n log.blank();\n\n const config = loadConfig(opts.dbPath ? { dataDir: opts.dbPath } : undefined);\n const dataDir = resolveDataDir(config.dataDir);\n\n // Step 1: Database\n log.step('[1/4] Setting up database...');\n if (!existsSync(dataDir)) {\n mkdirSync(dataDir, { recursive: true });\n }\n const db = createDatabase({ dataDir });\n migrate(db);\n closeDatabase(db);\n log.success(`${dataDir}/memory.db ready`);\n\n // Step 2: Configure Claude Code settings\n log.step('[2/4] Configuring Claude Code...');\n await configureSettings(process.cwd());\n\n // Step 3: Register MCP server\n log.step('[3/4] Registering MCP server...');\n const registered = registerMcpServer();\n if (registered) {\n log.success('MCP server registered via `claude mcp add`');\n } else {\n log.warn('Could not register MCP server automatically.');\n log.info('Run: claude mcp add agentic-memory -- npx claude-launchpad memory serve');\n }\n\n // Step 4: CLAUDE.md + skills\n log.step('[4/4] Injecting guidance...');\n const guidanceAdded = injectClaudeMdGuidance(process.cwd());\n if (guidanceAdded) {\n log.success('Memory guidance added to CLAUDE.md');\n }\n const skillsInstalled = installSkills(process.cwd());\n if (skillsInstalled > 0) {\n log.success(`Installed ${skillsInstalled} skill(s) to .claude/skills/`);\n }\n\n log.blank();\n log.success('Memory system installed.');\n log.info('Restart your Claude Code session for the MCP server to connect.');\n log.blank();\n}\n\nasync function configureSettings(projectDir: string): Promise<void> {\n const settings = await readSettingsJson(projectDir);\n\n // Disable built-in auto-memory\n settings['autoMemoryEnabled'] = false;\n log.info('Built-in auto-memory disabled');\n\n // SessionStart hook\n const hooks = (settings['hooks'] ?? {}) as Record<string, unknown[]>;\n addSessionStartHook(hooks);\n addStopHook(hooks);\n settings['hooks'] = hooks;\n\n // Auto-allow MCP tools\n addToolPermissions(settings);\n\n await writeSettingsJson(projectDir, settings);\n log.success('settings.json updated');\n}\n\nfunction addSessionStartHook(hooks: Record<string, unknown[]>): void {\n const sessionStartHooks = (hooks['SessionStart'] ?? []) as Record<string, unknown>[];\n const hookCommand = 'npx claude-launchpad memory context --json 2>/dev/null; exit 0';\n\n const alreadyHooked = sessionStartHooks.some((h) => {\n const innerHooks = h['hooks'] as Record<string, unknown>[] | undefined;\n return innerHooks?.some(\n ih => typeof ih['command'] === 'string' && (ih['command'] as string).includes('claude-launchpad memory context'),\n );\n });\n\n if (!alreadyHooked) {\n sessionStartHooks.push({\n matcher: 'startup|resume',\n hooks: [{ type: 'command', command: hookCommand }],\n });\n hooks['SessionStart'] = sessionStartHooks;\n log.info('SessionStart hook added (injects memory context)');\n }\n}\n\nfunction addStopHook(hooks: Record<string, unknown[]>): void {\n const stopHooks = (hooks['Stop'] ?? []) as Record<string, unknown>[];\n const extractCommand = 'npx claude-launchpad memory extract 2>/dev/null; exit 0';\n\n const alreadyHasExtract = stopHooks.some((h) => {\n const innerHooks = h['hooks'] as Record<string, unknown>[] | undefined;\n return innerHooks?.some(\n ih => typeof ih['command'] === 'string' && (ih['command'] as string).includes('claude-launchpad memory extract'),\n );\n });\n\n if (!alreadyHasExtract) {\n stopHooks.push({\n hooks: [{ type: 'command', command: extractCommand, async: true }],\n });\n hooks['Stop'] = stopHooks;\n log.info('Stop hook added (extracts facts from transcript)');\n }\n}\n\nfunction addToolPermissions(settings: Record<string, unknown>): void {\n const permissions = (settings['permissions'] ?? {}) as Record<string, unknown>;\n const allowList = (permissions['allow'] ?? []) as string[];\n\n const memoryTools = [\n 'mcp__agentic-memory__memory_store',\n 'mcp__agentic-memory__memory_search',\n 'mcp__agentic-memory__memory_recent',\n 'mcp__agentic-memory__memory_forget',\n 'mcp__agentic-memory__memory_relate',\n 'mcp__agentic-memory__memory_stats',\n 'mcp__agentic-memory__memory_update',\n ];\n\n let added = 0;\n for (const tool of memoryTools) {\n if (!allowList.includes(tool)) {\n allowList.push(tool);\n added++;\n }\n }\n\n if (added > 0) {\n permissions['allow'] = allowList;\n settings['permissions'] = permissions;\n log.info(`Auto-allowed ${added} MCP tools`);\n }\n}\n\nfunction registerMcpServer(): boolean {\n try {\n execSync(\n 'claude mcp add --scope user agentic-memory -- npx claude-launchpad memory serve',\n { stdio: 'pipe', timeout: 10000 },\n );\n return true;\n } catch {\n return false;\n }\n}\n\nconst MEMORY_GUIDANCE = `\n## Memory (agentic-memory)\nThis project uses **agentic-memory** for persistent memory across sessions.\n- **DO NOT** use the built-in auto-memory system (~/.claude/projects/*/memory/)\n- Memory context is **automatically injected** at session start via SessionStart hook - no need to call memory_recent manually\n- Use \\`memory_search\\` to find specific memories by keyword\n- Use \\`memory_store\\` to save decisions, gotchas, and learnings worth remembering\n- Use \\`memory_stats\\` to check memory health\n`;\n\nfunction injectClaudeMdGuidance(projectDir: string): boolean {\n const claudeMdPath = join(projectDir, 'CLAUDE.md');\n\n let content = '';\n try {\n content = readFileSync(claudeMdPath, 'utf-8');\n } catch {\n return false;\n }\n\n if (content.includes('## Memory (agentic-memory)')) {\n return false;\n }\n\n const updated = content.trimEnd() + '\\n' + MEMORY_GUIDANCE;\n writeFileSync(claudeMdPath, updated, 'utf-8');\n return true;\n}\n\nconst MIGRATE_MEMORY_SKILL = `---\nname: lp-migrate-memory\ndescription: Migrate legacy Claude Code auto-memory files (~/.claude/projects/*/memory/*.md) into agentic-memory. Use when setting up agentic-memory on a project that already has built-in memories.\nallowed-tools: Read, Glob, Grep, mcp__agentic-memory__memory_store, mcp__agentic-memory__memory_search\n---\n\n# Migrate Legacy Claude Code Memories\n\nMigrate memory files from Claude Code's built-in auto-memory system into agentic-memory.\n\n## Steps\n\n1. **Find legacy memory files** for this project:\n - Scan \\`~/.claude/projects/*/memory/*.md\\` for directories whose slug matches the current project path\n - The slug format is the absolute path with \\`/\\` replaced by \\`-\\` and leading \\`-\\` (e.g. \\`-Users-john-projects-myapp\\`)\n - Also check \\`~/.claude/projects/*/memory/team/*.md\\` for team memories\n\n2. **For each memory file found**, read it and parse:\n - YAML frontmatter: \\`name\\`, \\`description\\`, \\`type\\` (user/feedback/project/reference)\n - Body content (everything after the frontmatter closing \\`---\\`)\n - Skip \\`MEMORY.md\\` (it's just an index file, not a memory)\n\n3. **Before storing**, check for duplicates:\n - Call \\`memory_search\\` with the memory description or first 100 chars of content\n - If a close match exists (same topic), skip it and report\n\n4. **Map types and store** each memory via \\`memory_store\\`:\n - \\`user\\` -> type: \\`semantic\\`, tags: [\\`user\\`, \\`migrated\\`], importance: 0.7\n - \\`feedback\\` -> type: \\`semantic\\`, tags: [\\`feedback\\`, \\`migrated\\`], importance: 0.8\n - \\`project\\` -> type: \\`semantic\\`, tags: [\\`project\\`, \\`migrated\\`], importance: 0.6\n - \\`reference\\` -> type: \\`semantic\\`, tags: [\\`reference\\`, \\`migrated\\`], importance: 0.5\n - Use the frontmatter \\`name\\` as the title\n - Use the body content as the memory content\n - Set source: \\`import\\`\n - Adjust importance up/down based on the content (decisions and gotchas deserve higher importance)\n\n5. **Report results**: list what was migrated, what was skipped (duplicates), and what failed\n\n## Important\n\n- Do NOT delete the original files - the user can do that manually after verifying\n- Do NOT migrate content that is purely derived from code (architecture, file structure) - it belongs in CLAUDE.md, not memory\n- If unsure about a memory's value, migrate it anyway - the decay system will naturally prune low-value memories over time\n`;\n\nconst SKILLS: Readonly<Record<string, string>> = {\n 'lp-migrate-memory': MIGRATE_MEMORY_SKILL,\n};\n\nfunction installSkills(projectDir: string): number {\n const skillsDir = join(projectDir, '.claude', 'skills');\n let installed = 0;\n\n for (const [name, content] of Object.entries(SKILLS)) {\n const skillDir = join(skillsDir, name);\n const skillPath = join(skillDir, 'SKILL.md');\n\n if (existsSync(skillPath)) continue;\n\n mkdirSync(skillDir, { recursive: true });\n writeFileSync(skillPath, content.trimStart(), 'utf-8');\n installed++;\n }\n\n return installed;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,WAAW,cAAc,qBAAqB;AACnE,SAAS,YAAY;AACrB,SAAS,gBAAgB;AAWzB,eAAsB,WAAW,MAAkC;AACjE,MAAI,MAAM;AACV,MAAI,KAAK,yBAAyB;AAClC,MAAI,MAAM;AAEV,QAAM,SAAS,WAAW,KAAK,SAAS,EAAE,SAAS,KAAK,OAAO,IAAI,MAAS;AAC5E,QAAM,UAAU,eAAe,OAAO,OAAO;AAG7C,MAAI,KAAK,8BAA8B;AACvC,MAAI,CAAC,WAAW,OAAO,GAAG;AACxB,cAAU,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACxC;AACA,QAAM,KAAK,eAAe,EAAE,QAAQ,CAAC;AACrC,UAAQ,EAAE;AACV,gBAAc,EAAE;AAChB,MAAI,QAAQ,GAAG,OAAO,kBAAkB;AAGxC,MAAI,KAAK,kCAAkC;AAC3C,QAAM,kBAAkB,QAAQ,IAAI,CAAC;AAGrC,MAAI,KAAK,iCAAiC;AAC1C,QAAM,aAAa,kBAAkB;AACrC,MAAI,YAAY;AACd,QAAI,QAAQ,4CAA4C;AAAA,EAC1D,OAAO;AACL,QAAI,KAAK,8CAA8C;AACvD,QAAI,KAAK,yEAAyE;AAAA,EACpF;AAGA,MAAI,KAAK,6BAA6B;AACtC,QAAM,gBAA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,OAAO;AAAA,EAC9C,QAAQ;AACN,WAAO;AAAA,EACT;AAEA,MAAI,QAAQ,SAAS,4BAA4B,GAAG;AAClD,WAAO;AAAA,EACT;AAEA,QAAM,UAAU,QAAQ,QAAQ,IAAI,OAAO;AAC3C,gBAAc,cAAc,SAAS,OAAO;AAC5C,SAAO;AACT;AAEA,IAAM,uBAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6C7B,IAAM,SAA2C;AAAA,EAC/C,qBAAqB;AACvB;AAEA,SAAS,cAAc,YAA4B;AACjD,QAAM,YAAY,KAAK,YAAY,WAAW,QAAQ;AACtD,MAAI,YAAY;AAEhB,aAAW,CAAC,MAAM,OAAO,KAAK,OAAO,QAAQ,MAAM,GAAG;AACpD,UAAM,WAAW,KAAK,WAAW,IAAI;AACrC,UAAM,YAAY,KAAK,UAAU,UAAU;AAE3C,QAAI,WAAW,SAAS,EAAG;AAE3B,cAAU,UAAU,EAAE,WAAW,KAAK,CAAC;AACvC,kBAAc,WAAW,QAAQ,UAAU,GAAG,OAAO;AACrD;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/memory/subcommands/stats.ts"],"sourcesContent":["import { existsSync, statSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { log } from '../../../lib/output.js';\nimport { initStorage } from './init-storage.js';\n\ninterface StatsOpts {\n readonly json?: boolean;\n readonly dbPath?: string;\n}\n\nfunction formatBytes(bytes: number): string {\n if (bytes < 1024) return `${bytes}B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)}KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;\n}\n\nexport async function runStats(opts: StatsOpts): Promise<void> {\n const ctx = initStorage(opts.dbPath);\n\n try {\n const total = ctx.memoryRepo.count();\n const byType = ctx.memoryRepo.countByType();\n const relations = ctx.relationRepo.count();\n const dateRange = ctx.memoryRepo.dateRange();\n const topInjected = ctx.memoryRepo.topInjected(5);\n\n let dbSize = 0;\n try {\n const dbPath = join(ctx.dataDir, 'memory.db');\n if (existsSync(dbPath)) {\n dbSize = statSync(dbPath).size;\n }\n } catch { /* ignore */ }\n\n if (opts.json) {\n process.stdout.write(JSON.stringify({\n totalMemories: total,\n byType,\n totalRelations: relations,\n dbSizeBytes: dbSize,\n oldestMemory: dateRange.oldest,\n newestMemory: dateRange.newest,\n topInjected,\n }, null, 2) + '\\n');\n } else {\n log.blank();\n log.step('Memory stats');\n log.info(`Memories: ${total}`);\n for (const [type, count] of Object.entries(byType)) {\n log.info(` ${type}: ${count}`);\n }\n log.info(`Relations: ${relations}`);\n log.info(`DB size: ${formatBytes(dbSize)}`);\n log.info(`Oldest: ${dateRange.oldest ?? 'none'}`);\n log.info(`Newest: ${dateRange.newest ?? 'none'}`);\n if (topInjected.length > 0) {\n log.blank();\n log.info('Top injected:');\n for (const m of topInjected) {\n log.info(` ${m.title ?? m.id} (${m.injectionCount}x)`);\n }\n }\n log.blank();\n }\n } finally {\n ctx.close();\n }\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,YAAY,gBAAgB;AACrC,SAAS,YAAY;AASrB,SAAS,YAAY,OAAuB;AAC1C,MAAI,QAAQ,KAAM,QAAO,GAAG,KAAK;AACjC,MAAI,QAAQ,OAAO,KAAM,QAAO,IAAI,QAAQ,MAAM,QAAQ,CAAC,CAAC;AAC5D,SAAO,IAAI,SAAS,OAAO,OAAO,QAAQ,CAAC,CAAC;AAC9C;AAEA,eAAsB,SAAS,MAAgC;AAC7D,QAAM,MAAM,YAAY,KAAK,MAAM;AAEnC,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