Implementation:0xK3vin MegaMemory Installer
| Knowledge Sources | |
|---|---|
| Domains | Editor_Integration, MCP, CLI |
| Last Updated | 2026-10-27 12:00 GMT |
Overview
Concrete installer for configuring MegaMemory MCP server integration with supported coding editors and AI agent environments.
Description
The Installer (src/install.ts) implements megamemory install, which configures MCP server entries, writes workflow instruction files, and copies skill plugins and slash commands for four supported targets: opencode, claudecode, antigravity, and codex. The installer is idempotent — it uses a MANAGED_FILE_MARKER so it only overwrites files it previously created, and it safely reads existing editor config (with JSONC comment stripping) rather than clobbering.
Key components:
- detectGlobalCommand — auto-detects whether megamemory is on PATH (global) or needs node <entry.js>
- setupOpencodeMcpConfig / setupClaudeConfig / setupAntigravityConfig / setupCodexConfig — write the MCP server entry into each editor's config file
- setupInstructionFile — appends the understand → work → update loop instructions to AGENTS.md / CLAUDE.md
- setupToolPlugin / setupCommand — copy the skill plugin and slash command files (idempotent, managed-marker guarded)
- parseTargets / chooseTargetsInteractively — select targets via --target flags or interactive multiSelect
- runInstall — orchestrates all steps and prints a per-target report
Usage
Import this module when you need to:
- Install MegaMemory into an editor: run megamemory install --target <editor>
- Interactive install: run megamemory install and select from the TTY prompt
- Programmatic install: call runInstall with an args array
Code Reference
Source Location
- Repository: 0xK3vin_MegaMemory
- File: src/install.ts
- Key functions:
- detectGlobalCommand: L206-234
- setupOpencodeMcpConfig: L337-364
- setupClaudeConfig: L366-387
- setupAntigravityConfig: L389-409
- setupCodexConfig: L472-497
- setupInstructionFile: L249-265
- setupToolPlugin: L267-301
- setupCommand: L303-335
- createTargetConfigs: L499-550
- parseTargets: L554-593
- chooseTargetsInteractively: L595-622
- runInstall: L624-724
Signature
export type InstallTarget = "opencode" | "claudecode" | "antigravity" | "codex";
interface CommandRuntime {
opencodeCommand: string[];
stdioCommand: string;
stdioArgs: string[];
}
async function detectGlobalCommand(): Promise<CommandRuntime>;
function setupInstructionFile(filePath: string): void;
function setupToolPlugin(): void;
function setupCommand(destinationDir: string, filename: string, label: string): void;
async function setupOpencodeMcpConfig(runtime: CommandRuntime): Promise<void>;
async function setupClaudeConfig(runtime: CommandRuntime): Promise<void>;
async function setupAntigravityConfig(runtime: CommandRuntime): Promise<void>;
async function setupCodexConfig(runtime: CommandRuntime): Promise<void>;
function parseTargets(args: string[]): InstallTarget[];
async function chooseTargetsInteractively(): Promise<InstallTarget[]>;
export async function runInstall(args: string[]): Promise<void>;
Import
import { runInstall } from "./install.js";
import type { InstallTarget } from "./install.js";
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| args | string[] | Yes (runInstall) | process.argv.slice(3); --target <name> (repeatable, comma-separated) |
| runtime | CommandRuntime | (internal) | From detectGlobalCommand; populates MCP command entry |
Outputs
| Name | Type | Description |
|---|---|---|
| runInstall() | void (console) | Per-target step report; Done. or Done with issues. |
| Config files | Files | Updated editor config with megamemory MCP entry |
| Instruction files | Files | AGENTS.md / CLAUDE.md with knowledge graph loop snippet |
| Plugin/commands | Files | Copied skill plugin and slash command files (managed) |
Usage Examples
Non-Interactive Install
# Install for Claude Code only
megamemory install --target claudecode
# Install for multiple targets
megamemory install --target opencode,claudecode,codex
Interactive Install
# No --target flag → interactive multiSelect
megamemory install
# Which editors would you like to configure?
# [x] opencode (MCP server, AGENTS.md, skill plugin, commands)
# [ ] Claude Code (MCP server, CLAUDE.md, commands)
# [ ] Antigravity (MCP server config, workspace-level)
# [ ] Codex (MCP server, AGENTS.md)
Programmatic Install
import { runInstall } from "./install.js";
// Equivalent to: megamemory install --target opencode,claudecode
await runInstall(["--target", "opencode,claudecode"]);