claude-launchpad 1.7.0 → 1.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/{chunk-ZI2PZSG4.js → chunk-N3K4VF6G.js} +4 -3
- package/dist/chunk-N3K4VF6G.js.map +1 -0
- package/dist/{chunk-DPMWZRFQ.js → chunk-N4GESFQC.js} +2 -2
- package/dist/{chunk-AGDE4BJA.js → chunk-UHZ2B7BE.js} +6 -6
- package/dist/chunk-UHZ2B7BE.js.map +1 -0
- package/dist/{chunk-RN257YFF.js → chunk-VLB5TDFF.js} +3 -3
- package/dist/{chunk-7I2BTZP3.js → chunk-XJZZJEXT.js} +2 -2
- package/dist/{chunk-3UJYOWGF.js → chunk-XL4ZMHA7.js} +36 -7
- package/dist/chunk-XL4ZMHA7.js.map +1 -0
- package/dist/cli.js +19 -19
- package/dist/cli.js.map +1 -1
- package/dist/commands/memory/server.js +4 -4
- package/dist/{context-G2GSE7TY.js → context-USZJ232G.js} +6 -6
- package/dist/{install-ZQQGCIRC.js → install-FUXDR2HU.js} +6 -6
- package/dist/install-FUXDR2HU.js.map +1 -0
- package/dist/{pull-TP2Y7CQS.js → pull-IZB5D5FC.js} +7 -7
- package/dist/{push-STHV7MT7.js → push-IUNXSJZ5.js} +7 -7
- package/dist/{require-deps-H2U4PXPY.js → require-deps-Z3CV2I3V.js} +3 -3
- package/dist/{stats-DGMDAUNG.js → stats-FMKE3T6J.js} +6 -6
- package/dist/{sync-clean-HLV2XJPT.js → sync-clean-33V4VWRI.js} +3 -3
- package/dist/{sync-status-XH3Z5LC5.js → sync-status-5GMPSUQF.js} +7 -7
- package/dist/{tui-NDDEYYND.js → tui-7YXGNXCP.js} +4 -4
- package/package.json +1 -1
- package/dist/chunk-3UJYOWGF.js.map +0 -1
- package/dist/chunk-AGDE4BJA.js.map +0 -1
- package/dist/chunk-ZI2PZSG4.js.map +0 -1
- package/dist/install-ZQQGCIRC.js.map +0 -1
- /package/dist/{chunk-DPMWZRFQ.js.map → chunk-N4GESFQC.js.map} +0 -0
- /package/dist/{chunk-RN257YFF.js.map → chunk-VLB5TDFF.js.map} +0 -0
- /package/dist/{chunk-7I2BTZP3.js.map → chunk-XJZZJEXT.js.map} +0 -0
- /package/dist/{context-G2GSE7TY.js.map → context-USZJ232G.js.map} +0 -0
- /package/dist/{pull-TP2Y7CQS.js.map → pull-IZB5D5FC.js.map} +0 -0
- /package/dist/{push-STHV7MT7.js.map → push-IUNXSJZ5.js.map} +0 -0
- /package/dist/{require-deps-H2U4PXPY.js.map → require-deps-Z3CV2I3V.js.map} +0 -0
- /package/dist/{stats-DGMDAUNG.js.map → stats-FMKE3T6J.js.map} +0 -0
- /package/dist/{sync-clean-HLV2XJPT.js.map → sync-clean-33V4VWRI.js.map} +0 -0
- /package/dist/{sync-status-XH3Z5LC5.js.map → sync-status-5GMPSUQF.js.map} +0 -0
- /package/dist/{tui-NDDEYYND.js.map → tui-7YXGNXCP.js.map} +0 -0
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
extractKeywords,
|
|
5
5
|
getGitContext,
|
|
6
6
|
smallerSetOverlap
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-N3K4VF6G.js";
|
|
8
8
|
import {
|
|
9
9
|
MEMORY_SOURCES,
|
|
10
10
|
MEMORY_TYPES,
|
|
@@ -26,9 +26,9 @@ import {
|
|
|
26
26
|
loadConfig,
|
|
27
27
|
migrate,
|
|
28
28
|
resolveDataDir
|
|
29
|
-
} from "../../chunk-
|
|
30
|
-
import "../../chunk-
|
|
31
|
-
import "../../chunk-
|
|
29
|
+
} from "../../chunk-VLB5TDFF.js";
|
|
30
|
+
import "../../chunk-XJZZJEXT.js";
|
|
31
|
+
import "../../chunk-UHZ2B7BE.js";
|
|
32
32
|
|
|
33
33
|
// src/commands/memory/server.ts
|
|
34
34
|
import { createRequire } from "module";
|
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
extractKeywords,
|
|
5
5
|
getGitContext,
|
|
6
6
|
jaccardOverlap
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-N3K4VF6G.js";
|
|
8
8
|
import {
|
|
9
9
|
detectProject
|
|
10
10
|
} from "./chunk-NAW47BYA.js";
|
|
11
11
|
import {
|
|
12
12
|
initStorage
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-N4GESFQC.js";
|
|
14
14
|
import "./chunk-DXDOVWOA.js";
|
|
15
15
|
import {
|
|
16
16
|
DEFAULT_DECAY_PARAMS,
|
|
@@ -28,9 +28,9 @@ import {
|
|
|
28
28
|
RECENCY_HALF_LIFE,
|
|
29
29
|
TYPE_INJECTION_BONUS,
|
|
30
30
|
estimateTokens
|
|
31
|
-
} from "./chunk-
|
|
32
|
-
import "./chunk-
|
|
33
|
-
import "./chunk-
|
|
31
|
+
} from "./chunk-VLB5TDFF.js";
|
|
32
|
+
import "./chunk-XJZZJEXT.js";
|
|
33
|
+
import "./chunk-UHZ2B7BE.js";
|
|
34
34
|
|
|
35
35
|
// src/commands/memory/subcommands/context.ts
|
|
36
36
|
import { readFileSync, writeFileSync } from "fs";
|
|
@@ -503,4 +503,4 @@ async function runContext(opts) {
|
|
|
503
503
|
export {
|
|
504
504
|
runContext
|
|
505
505
|
};
|
|
506
|
-
//# sourceMappingURL=context-
|
|
506
|
+
//# sourceMappingURL=context-USZJ232G.js.map
|
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
loadConfig,
|
|
6
6
|
migrate,
|
|
7
7
|
resolveDataDir
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-VLB5TDFF.js";
|
|
9
|
+
import "./chunk-XJZZJEXT.js";
|
|
10
10
|
import {
|
|
11
11
|
getMemoryPlacement,
|
|
12
12
|
log,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
readSettingsLocalJson,
|
|
15
15
|
writeSettingsJson,
|
|
16
16
|
writeSettingsLocalJson
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-UHZ2B7BE.js";
|
|
18
18
|
|
|
19
19
|
// src/commands/memory/subcommands/install.ts
|
|
20
20
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
@@ -155,7 +155,7 @@ function addSessionEndPushHook(hooks) {
|
|
|
155
155
|
});
|
|
156
156
|
if (alreadyHooked) return hooks;
|
|
157
157
|
const entry = {
|
|
158
|
-
hooks: [{ type: "command", command: "claude-launchpad memory push -y >/dev/null 2>&1
|
|
158
|
+
hooks: [{ type: "command", command: "nohup claude-launchpad memory push -y </dev/null >/dev/null 2>&1 & exit 0" }]
|
|
159
159
|
};
|
|
160
160
|
log.info("Session end: memories will auto-push to GitHub Gist");
|
|
161
161
|
return { ...hooks, SessionEnd: [...sessionEndHooks, entry] };
|
|
@@ -181,7 +181,7 @@ function addToolPermissions(settings) {
|
|
|
181
181
|
};
|
|
182
182
|
}
|
|
183
183
|
async function ensureNativeDeps() {
|
|
184
|
-
const { cwdRequire } = await import("./require-deps-
|
|
184
|
+
const { cwdRequire } = await import("./require-deps-Z3CV2I3V.js");
|
|
185
185
|
try {
|
|
186
186
|
cwdRequire("better-sqlite3");
|
|
187
187
|
return;
|
|
@@ -308,4 +308,4 @@ export {
|
|
|
308
308
|
detectExistingSetup,
|
|
309
309
|
runInstall
|
|
310
310
|
};
|
|
311
|
-
//# sourceMappingURL=install-
|
|
311
|
+
//# sourceMappingURL=install-FUXDR2HU.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, readSettingsLocalJson, writeSettingsLocalJson } from '../../../lib/settings.js';\nimport { getMemoryPlacement } from '../../../lib/memory-placement.js';\nimport { log } from '../../../lib/output.js';\nimport type { MemoryPlacement } from '../../../types/index.js';\n\nfunction isGhAuthenticated(): boolean {\n try {\n execSync('gh auth status', { stdio: 'pipe', timeout: 5000 });\n return true;\n } catch {\n return false;\n }\n}\n\ninterface InstallOpts {\n readonly dbPath?: string;\n}\n\nexport async function runInstall(opts: InstallOpts): Promise<void> {\n log.blank();\n log.step('Setting up your knowledge base');\n log.blank();\n\n // Step 0: Ensure native deps are installed globally\n await ensureNativeDeps();\n\n // Prompt for placement before any config writes\n const placement = await getMemoryPlacement(process.cwd());\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/5] Creating knowledge base...');\n if (!existsSync(dataDir)) {\n mkdirSync(dataDir, { recursive: true });\n }\n const db = createDatabase({ dataDir });\n migrate(db);\n closeDatabase(db);\n log.success(`Knowledge base created at ${dataDir}/memory.db`);\n\n // Step 2: Configure Claude Code settings\n log.step('[2/5] Connecting to Claude Code...');\n await configureSettings(process.cwd(), placement);\n\n // Step 3: Register MCP server (project scope for shared, local scope for local)\n log.step('[3/5] Enabling memory tools...');\n const mcpScope = placement === \"local\" ? \"local\" : \"project\";\n const registered = registerMcpServer(mcpScope);\n if (registered) {\n log.success('Memory tools available in Claude Code');\n } else {\n log.warn('Could not enable memory tools automatically.');\n log.info(`Run: claude mcp add --scope ${mcpScope} agentic-memory -- npx claude-launchpad memory serve`);\n }\n\n // Step 4: CLAUDE.md + skills\n log.step('[4/5] Adding instructions...');\n const guidanceAdded = injectClaudeMdGuidance(process.cwd(), placement);\n if (guidanceAdded) {\n const label = placement === \"local\" ? \".claude/CLAUDE.md\" : \"CLAUDE.md\";\n log.success(`${label} updated with memory instructions`);\n }\n if (placement === \"shared\") {\n const skillsInstalled = installSkills(process.cwd());\n if (skillsInstalled > 0) {\n log.success(`Installed ${skillsInstalled} skill(s) to .claude/skills/`);\n }\n }\n\n log.blank();\n log.success('Knowledge base is ready. Claude will now remember across sessions.');\n log.info('Restart your Claude Code session to activate.');\n\n // Sync guidance\n if (isGhAuthenticated()) {\n log.info('Cross-device sync available. Run `memory push` to back up, or it auto-syncs each session.');\n } else {\n log.blank();\n log.info('Recommended: install the GitHub CLI for cross-device memory sync:');\n log.step(' https://cli.github.com/');\n log.step(' gh auth login');\n }\n log.blank();\n}\n\nexport function detectExistingSetup(projectDir: string): MemoryPlacement | null {\n // Check local CLAUDE.md\n try {\n const localClaude = readFileSync(join(projectDir, '.claude', 'CLAUDE.md'), 'utf-8');\n if (localClaude.includes('## Memory') || localClaude.includes('agentic-memory')) return \"local\";\n } catch { /* not found */ }\n\n // Check root CLAUDE.md\n try {\n const rootClaude = readFileSync(join(projectDir, 'CLAUDE.md'), 'utf-8');\n if (rootClaude.includes('## Memory (agentic-memory)')) return \"shared\";\n } catch { /* not found */ }\n\n return null;\n}\n\nasync function configureSettings(projectDir: string, placement: MemoryPlacement): Promise<void> {\n const read = placement === \"local\" ? readSettingsLocalJson : readSettingsJson;\n const write = placement === \"local\" ? writeSettingsLocalJson : writeSettingsJson;\n const settings = await read(projectDir);\n\n // Disable built-in auto-memory\n log.info('Built-in auto-memory disabled (replaced by knowledge base)');\n\n // Build hooks immutably — always add sync hooks (they fail silently without gh)\n const baseHooks = (settings['hooks'] ?? {}) as Record<string, unknown[]>;\n const withPull = addSessionStartPullHook(baseHooks);\n const withContext = addSessionStartHook(withPull);\n const withPush = addSessionEndPushHook(withContext);\n\n // Build permissions immutably\n const withPermissions = addToolPermissions(settings);\n\n const updated = {\n ...withPermissions,\n autoMemoryEnabled: false,\n hooks: withPush,\n };\n\n await write(projectDir, updated);\n const target = placement === \"local\" ? \"settings.local.json\" : \"settings.json\";\n log.success(`Claude Code configured in ${target}`);\n}\n\nfunction addSessionStartPullHook(hooks: Record<string, unknown[]>): Record<string, unknown[]> {\n const sessionStartHooks = (hooks['SessionStart'] ?? []) as Record<string, unknown>[];\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('memory pull'),\n );\n });\n\n if (alreadyHooked) return hooks;\n\n // Insert at the beginning so pull runs before context injection\n const entry = {\n matcher: 'startup',\n hooks: [{ type: 'command', command: 'claude-launchpad memory pull -y 2>/dev/null; exit 0' }],\n };\n log.info('Session start: memories will auto-pull from GitHub Gist');\n return { ...hooks, SessionStart: [entry, ...sessionStartHooks] };\n}\n\nfunction addSessionStartHook(hooks: Record<string, unknown[]>): Record<string, unknown[]> {\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) return hooks;\n\n const entry = {\n matcher: 'startup|resume',\n hooks: [{ type: 'command', command: hookCommand }],\n };\n log.info('Session start: Claude will recall relevant context automatically');\n return { ...hooks, SessionStart: [...sessionStartHooks, entry] };\n}\n\nfunction addSessionEndPushHook(hooks: Record<string, unknown[]>): Record<string, unknown[]> {\n const sessionEndHooks = (hooks['SessionEnd'] ?? []) as Record<string, unknown>[];\n const alreadyHooked = sessionEndHooks.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('memory push'),\n );\n });\n\n if (alreadyHooked) return hooks;\n\n const entry = {\n hooks: [{ type: 'command', command: 'nohup claude-launchpad memory push -y </dev/null >/dev/null 2>&1 & exit 0' }],\n };\n log.info('Session end: memories will auto-push to GitHub Gist');\n return { ...hooks, SessionEnd: [...sessionEndHooks, entry] };\n}\n\nfunction addToolPermissions(settings: Record<string, unknown>): Record<string, unknown> {\n const permissions = (settings['permissions'] ?? {}) as Record<string, unknown>;\n const allowList = (permissions['allow'] ?? []) as readonly 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 const missing = memoryTools.filter((t) => !allowList.includes(t));\n if (missing.length === 0) return settings;\n\n log.info(`${missing.length} memory tools auto-approved`);\n return {\n ...settings,\n permissions: { ...permissions, allow: [...allowList, ...missing] },\n };\n}\n\nasync function ensureNativeDeps(): Promise<void> {\n const { cwdRequire } = await import('../utils/require-deps.js');\n try {\n cwdRequire('better-sqlite3');\n return;\n } catch {\n // Not installed — install globally\n }\n\n log.step('Installing required database libraries...');\n try {\n execSync('npm install -g better-sqlite3 sqlite-vec', { stdio: 'pipe', timeout: 120000 });\n log.success('Database libraries installed');\n } catch {\n log.error('Could not install database libraries automatically.');\n log.blank();\n log.info('Install manually:');\n log.step(' npm install -g better-sqlite3 sqlite-vec');\n log.blank();\n log.info('Requires a C++ compiler (Xcode on macOS, build-essential on Linux).');\n process.exit(1);\n }\n}\n\nfunction registerMcpServer(scope: \"project\" | \"local\"): boolean {\n try {\n const existing = execSync('claude mcp list', { stdio: 'pipe', timeout: 10000, encoding: 'utf-8' });\n if (existing.includes('agentic-memory')) {\n log.info('Memory tools already registered');\n return true;\n }\n execSync(\n `claude mcp add --scope ${scope} 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- **STORE IMMEDIATELY** when: a dependency strategy changes, an architecture decision is made, a convention is established, a bug pattern is discovered, or a feature is killed/added\n`;\n\nfunction injectClaudeMdGuidance(projectDir: string, placement: MemoryPlacement): boolean {\n const claudeMdPath = placement === \"local\"\n ? join(projectDir, '.claude', 'CLAUDE.md')\n : join(projectDir, 'CLAUDE.md');\n\n let content = '';\n try {\n content = readFileSync(claudeMdPath, 'utf-8');\n } catch {\n if (placement !== \"local\") return false;\n // Create local .claude/CLAUDE.md\n mkdirSync(join(projectDir, '.claude'), { recursive: true });\n content = '# Local Claude Config\\n';\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;AASzB,SAAS,oBAA6B;AACpC,MAAI;AACF,aAAS,kBAAkB,EAAE,OAAO,QAAQ,SA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C/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":[]}
|
|
@@ -10,20 +10,20 @@ import {
|
|
|
10
10
|
loadSyncConfig,
|
|
11
11
|
projectToFilename,
|
|
12
12
|
readGistFile
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-XL4ZMHA7.js";
|
|
14
14
|
import "./chunk-YZ53W47Z.js";
|
|
15
15
|
import {
|
|
16
16
|
detectProject
|
|
17
17
|
} from "./chunk-NAW47BYA.js";
|
|
18
18
|
import {
|
|
19
19
|
initStorage
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-N4GESFQC.js";
|
|
21
21
|
import "./chunk-DXDOVWOA.js";
|
|
22
|
-
import "./chunk-
|
|
23
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-VLB5TDFF.js";
|
|
23
|
+
import "./chunk-XJZZJEXT.js";
|
|
24
24
|
import {
|
|
25
25
|
log
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-UHZ2B7BE.js";
|
|
27
27
|
|
|
28
28
|
// src/commands/memory/subcommands/pull.ts
|
|
29
29
|
async function runPull(opts) {
|
|
@@ -33,7 +33,7 @@ async function runPull(opts) {
|
|
|
33
33
|
log.error("No sync gist found. Run `memory push` first.");
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
|
-
const { requireMemoryDeps } = await import("./require-deps-
|
|
36
|
+
const { requireMemoryDeps } = await import("./require-deps-Z3CV2I3V.js");
|
|
37
37
|
await requireMemoryDeps();
|
|
38
38
|
const ctx = initStorage();
|
|
39
39
|
try {
|
|
@@ -137,4 +137,4 @@ function printResult(result, project) {
|
|
|
137
137
|
export {
|
|
138
138
|
runPull
|
|
139
139
|
};
|
|
140
|
-
//# sourceMappingURL=pull-
|
|
140
|
+
//# sourceMappingURL=pull-IZB5D5FC.js.map
|
|
@@ -12,20 +12,20 @@ import {
|
|
|
12
12
|
projectToFilename,
|
|
13
13
|
readGistFile,
|
|
14
14
|
updateGistFiles
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-XL4ZMHA7.js";
|
|
16
16
|
import "./chunk-YZ53W47Z.js";
|
|
17
17
|
import {
|
|
18
18
|
detectProject
|
|
19
19
|
} from "./chunk-NAW47BYA.js";
|
|
20
20
|
import {
|
|
21
21
|
initStorage
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-N4GESFQC.js";
|
|
23
23
|
import "./chunk-DXDOVWOA.js";
|
|
24
|
-
import "./chunk-
|
|
25
|
-
import "./chunk-
|
|
24
|
+
import "./chunk-VLB5TDFF.js";
|
|
25
|
+
import "./chunk-XJZZJEXT.js";
|
|
26
26
|
import {
|
|
27
27
|
log
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-UHZ2B7BE.js";
|
|
29
29
|
|
|
30
30
|
// src/commands/memory/subcommands/push.ts
|
|
31
31
|
import { hostname } from "os";
|
|
@@ -50,7 +50,7 @@ function filterRelations(allRelations, memoryIds) {
|
|
|
50
50
|
}
|
|
51
51
|
async function runPush(opts) {
|
|
52
52
|
assertGhAvailable();
|
|
53
|
-
const { requireMemoryDeps } = await import("./require-deps-
|
|
53
|
+
const { requireMemoryDeps } = await import("./require-deps-Z3CV2I3V.js");
|
|
54
54
|
await requireMemoryDeps();
|
|
55
55
|
const ctx = initStorage();
|
|
56
56
|
try {
|
|
@@ -171,4 +171,4 @@ async function confirmCreate() {
|
|
|
171
171
|
export {
|
|
172
172
|
runPush
|
|
173
173
|
};
|
|
174
|
-
//# sourceMappingURL=push-
|
|
174
|
+
//# sourceMappingURL=push-IUNXSJZ5.js.map
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import {
|
|
3
3
|
cwdRequire,
|
|
4
4
|
requireMemoryDeps
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-XJZZJEXT.js";
|
|
6
|
+
import "./chunk-UHZ2B7BE.js";
|
|
7
7
|
export {
|
|
8
8
|
cwdRequire,
|
|
9
9
|
requireMemoryDeps
|
|
10
10
|
};
|
|
11
|
-
//# sourceMappingURL=require-deps-
|
|
11
|
+
//# sourceMappingURL=require-deps-Z3CV2I3V.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
initStorage
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-N4GESFQC.js";
|
|
5
5
|
import "./chunk-DXDOVWOA.js";
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-VLB5TDFF.js";
|
|
7
|
+
import "./chunk-XJZZJEXT.js";
|
|
8
8
|
import {
|
|
9
9
|
log
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-UHZ2B7BE.js";
|
|
11
11
|
|
|
12
12
|
// src/commands/memory/subcommands/stats.ts
|
|
13
13
|
import { existsSync, statSync } from "fs";
|
|
@@ -18,7 +18,7 @@ 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-
|
|
21
|
+
const { requireMemoryDeps } = await import("./require-deps-Z3CV2I3V.js");
|
|
22
22
|
await requireMemoryDeps();
|
|
23
23
|
const ctx = initStorage(opts.dbPath);
|
|
24
24
|
try {
|
|
@@ -72,4 +72,4 @@ async function runStats(opts) {
|
|
|
72
72
|
export {
|
|
73
73
|
runStats
|
|
74
74
|
};
|
|
75
|
-
//# sourceMappingURL=stats-
|
|
75
|
+
//# sourceMappingURL=stats-FMKE3T6J.js.map
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
listGistFiles,
|
|
7
7
|
loadSyncConfig,
|
|
8
8
|
projectToFilename
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-XL4ZMHA7.js";
|
|
10
10
|
import {
|
|
11
11
|
log
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-UHZ2B7BE.js";
|
|
13
13
|
|
|
14
14
|
// src/commands/memory/subcommands/sync-clean.ts
|
|
15
15
|
import { confirm } from "@inquirer/prompts";
|
|
@@ -50,4 +50,4 @@ async function runSyncClean(project, opts) {
|
|
|
50
50
|
export {
|
|
51
51
|
runSyncClean
|
|
52
52
|
};
|
|
53
|
-
//# sourceMappingURL=sync-clean-
|
|
53
|
+
//# sourceMappingURL=sync-clean-33V4VWRI.js.map
|
|
@@ -8,17 +8,17 @@ import {
|
|
|
8
8
|
listGistFiles,
|
|
9
9
|
loadSyncConfig,
|
|
10
10
|
readGistFile
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-XL4ZMHA7.js";
|
|
12
12
|
import "./chunk-YZ53W47Z.js";
|
|
13
13
|
import {
|
|
14
14
|
initStorage
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-N4GESFQC.js";
|
|
16
16
|
import "./chunk-DXDOVWOA.js";
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-VLB5TDFF.js";
|
|
18
|
+
import "./chunk-XJZZJEXT.js";
|
|
19
19
|
import {
|
|
20
20
|
log
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-UHZ2B7BE.js";
|
|
22
22
|
|
|
23
23
|
// src/commands/memory/subcommands/sync-status.ts
|
|
24
24
|
async function runSyncStatus() {
|
|
@@ -28,7 +28,7 @@ async function runSyncStatus() {
|
|
|
28
28
|
log.error("No sync gist found. Run `memory push` first.");
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
-
const { requireMemoryDeps } = await import("./require-deps-
|
|
31
|
+
const { requireMemoryDeps } = await import("./require-deps-Z3CV2I3V.js");
|
|
32
32
|
await requireMemoryDeps();
|
|
33
33
|
const ctx = initStorage();
|
|
34
34
|
try {
|
|
@@ -67,4 +67,4 @@ async function runSyncStatus() {
|
|
|
67
67
|
export {
|
|
68
68
|
runSyncStatus
|
|
69
69
|
};
|
|
70
|
-
//# sourceMappingURL=sync-status-
|
|
70
|
+
//# sourceMappingURL=sync-status-5GMPSUQF.js.map
|
|
@@ -11,9 +11,9 @@ import {
|
|
|
11
11
|
loadConfig,
|
|
12
12
|
migrate,
|
|
13
13
|
resolveDataDir
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-VLB5TDFF.js";
|
|
15
|
+
import "./chunk-XJZZJEXT.js";
|
|
16
|
+
import "./chunk-UHZ2B7BE.js";
|
|
17
17
|
|
|
18
18
|
// src/commands/memory/dashboard/tui.tsx
|
|
19
19
|
import { render } from "ink";
|
|
@@ -1306,4 +1306,4 @@ async function startTui(options) {
|
|
|
1306
1306
|
export {
|
|
1307
1307
|
startTui
|
|
1308
1308
|
};
|
|
1309
|
-
//# sourceMappingURL=tui-
|
|
1309
|
+
//# sourceMappingURL=tui-7YXGNXCP.js.map
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/memory/utils/gist-transport.ts"],"sourcesContent":["import { execSync } from 'node:child_process';\nimport { readFileSync, writeFileSync, unlinkSync, mkdirSync } from 'node:fs';\nimport { join, dirname } from 'node:path';\nimport { tmpdir } from 'node:os';\nimport { homedir } from 'node:os';\n\nexport interface SyncConfig {\n readonly gistId: string;\n}\n\nconst EXEC_OPTS = { encoding: 'utf-8' as const, timeout: 30_000 };\nconst GIST_DESCRIPTION = 'agentic-memory sync';\nconst SYNC_CONFIG_FILE = 'sync-config.json';\nconst DATA_DIR = join(homedir(), '.agentic-memory');\n\nfunction syncConfigPath(): string {\n return join(DATA_DIR, SYNC_CONFIG_FILE);\n}\n\nfunction slugify(project: string): string {\n return project.replace(/[^a-zA-Z0-9._-]/g, '-');\n}\n\nexport function projectToFilename(project: string): string {\n if (!project) throw new Error('Project name cannot be empty');\n return `memories-${slugify(project)}.json`;\n}\n\nexport function filenameToProject(filename: string): string | null {\n const match = filename.match(/^memories-(.+)\\.json$/);\n return match?.[1] ?? null;\n}\n\n\nexport function assertGhAvailable(): void {\n try {\n execSync('gh --version', { ...EXEC_OPTS, stdio: 'pipe' });\n } catch {\n throw new Error(\n 'Memory sync requires the GitHub CLI.\\n' +\n 'Install: https://cli.github.com/\\n' +\n 'Then run: gh auth login'\n );\n }\n try {\n execSync('gh auth status', { ...EXEC_OPTS, stdio: 'pipe' });\n } catch {\n throw new Error(\n 'gh is installed but not authenticated.\\n' +\n 'Run: gh auth login'\n );\n }\n}\n\n/**\n * Read sync config from disk only — no network discovery.\n * Safe to call from lightweight contexts like doctor analyzers.\n */\nexport function readSyncConfig(): SyncConfig | null {\n try {\n const raw = readFileSync(syncConfigPath(), 'utf-8');\n const parsed = JSON.parse(raw) as Record<string, unknown>;\n if (typeof parsed.gistId === 'string' && /^[a-f0-9]+$/.test(parsed.gistId)) {\n return { gistId: parsed.gistId };\n }\n } catch { /* no config file */ }\n return null;\n}\n\nexport function loadSyncConfig(): SyncConfig | null {\n try {\n const raw = readFileSync(syncConfigPath(), 'utf-8');\n const parsed = JSON.parse(raw) as Record<string, unknown>;\n if (typeof parsed.gistId === 'string' && /^[a-f0-9]+$/.test(parsed.gistId)) {\n return { gistId: parsed.gistId };\n }\n } catch { /* no local config */ }\n\n const discovered = discoverSyncGist();\n if (discovered) {\n saveSyncConfig({ gistId: discovered });\n return { gistId: discovered };\n }\n return null;\n}\n\nfunction discoverSyncGist(): string | null {\n try {\n const output = execSync(\n 'gh gist list --limit 100',\n { ...EXEC_OPTS, stdio: ['pipe', 'pipe', 'pipe'] },\n );\n for (const line of output.split('\\n')) {\n const cols = line.split('\\t');\n if (cols[1]?.trim() === GIST_DESCRIPTION) {\n const gistId = cols[0]?.trim();\n if (gistId && /^[a-f0-9]+$/.test(gistId)) return gistId;\n }\n }\n } catch { /* gh list failed */ }\n return null;\n}\n\nexport function saveSyncConfig(config: SyncConfig): void {\n const filePath = syncConfigPath();\n mkdirSync(dirname(filePath), { recursive: true });\n writeFileSync(filePath, JSON.stringify(config, null, 2) + '\\n', 'utf-8');\n}\n\nexport function createGist(filename: string, content: string): string {\n const safeFilename = slugify(filename.replace(/\\.json$/, '')) + '.json';\n const tmpFile = join(tmpdir(), safeFilename);\n try {\n writeFileSync(tmpFile, content, 'utf-8');\n const result = execSync(\n `gh gist create \"${tmpFile}\" --desc \"${GIST_DESCRIPTION}\" --public=false`,\n { ...EXEC_OPTS, stdio: ['pipe', 'pipe', 'pipe'] },\n ).trim();\n const gistId = result.split('/').pop()?.trim() ?? '';\n if (!gistId || !/^[a-f0-9]+$/.test(gistId)) {\n throw new Error(`Failed to parse gist ID from: ${result}`);\n }\n saveSyncConfig({ gistId });\n return gistId;\n } finally {\n try { unlinkSync(tmpFile); } catch { /* ignore */ }\n }\n}\n\nexport function readGistFile(gistId: string, filename: string): string | null {\n try {\n const escapedFilename = JSON.stringify(filename);\n return execSync(\n `gh api \"/gists/${gistId}\" --jq '.files[${escapedFilename}].content'`,\n { ...EXEC_OPTS, stdio: ['pipe', 'pipe', 'pipe'] },\n ).trimEnd();\n } catch {\n return null;\n }\n}\n\nexport function listGistFiles(gistId: string): readonly string[] {\n try {\n const output = execSync(\n `gh api \"/gists/${gistId}\" --jq '.files | keys[]'`,\n { ...EXEC_OPTS, stdio: ['pipe', 'pipe', 'pipe'] },\n );\n return output.trim().split('\\n').filter(Boolean);\n } catch {\n return [];\n }\n}\n\nexport function deleteGistFile(gistId: string, filename: string): void {\n const payload = { files: { [filename]: null } };\n const tmpFile = join(tmpdir(), `gist-delete-${Date.now()}.json`);\n try {\n writeFileSync(tmpFile, JSON.stringify(payload), 'utf-8');\n execSync(\n `gh api --method PATCH \"/gists/${gistId}\" --input \"${tmpFile}\"`,\n { ...EXEC_OPTS, stdio: ['pipe', 'pipe', 'pipe'] },\n );\n } finally {\n try { unlinkSync(tmpFile); } catch { /* ignore */ }\n }\n}\n\nexport function updateGistFiles(\n gistId: string,\n files: Record<string, string>,\n): void {\n const payload = {\n files: Object.fromEntries(\n Object.entries(files).map(([name, content]) => [name, { content }]),\n ),\n };\n const tmpFile = join(tmpdir(), `gist-patch-${Date.now()}.json`);\n try {\n writeFileSync(tmpFile, JSON.stringify(payload), 'utf-8');\n execSync(\n `gh api --method PATCH \"/gists/${gistId}\" --input \"${tmpFile}\"`,\n { ...EXEC_OPTS, stdio: ['pipe', 'pipe', 'pipe'] },\n );\n } finally {\n try { unlinkSync(tmpFile); } catch { /* ignore */ }\n }\n}\n"],"mappings":";;;AAAA,SAAS,gBAAgB;AACzB,SAAS,cAAc,eAAe,YAAY,iBAAiB;AACnE,SAAS,MAAM,eAAe;AAC9B,SAAS,cAAc;AACvB,SAAS,eAAe;AAMxB,IAAM,YAAY,EAAE,UAAU,SAAkB,SAAS,IAAO;AAChE,IAAM,mBAAmB;AACzB,IAAM,mBAAmB;AACzB,IAAM,WAAW,KAAK,QAAQ,GAAG,iBAAiB;AAElD,SAAS,iBAAyB;AAChC,SAAO,KAAK,UAAU,gBAAgB;AACxC;AAEA,SAAS,QAAQ,SAAyB;AACxC,SAAO,QAAQ,QAAQ,oBAAoB,GAAG;AAChD;AAEO,SAAS,kBAAkB,SAAyB;AACzD,MAAI,CAAC,QAAS,OAAM,IAAI,MAAM,8BAA8B;AAC5D,SAAO,YAAY,QAAQ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