Skip to main content

Module install

Module install 

Source
Expand description

ai-memory install <agent> — wire ai-memory boot and the ai-memory-mcp server into AI agents’ config files (issue #487 PR-2/3).

Each target writes a precisely-marked managed block so re-running install is a no-op and --uninstall removes the block surgically without disturbing user-added keys.

§Behavior summary

  • Default --dry-run: prints the diff (pretty before/after JSON, plus a unified diff over the JSON serialization) and writes nothing.
  • --apply: writes the modified config; backs up the original to <config>.bak.<timestamp> first.
  • --uninstall: removes the managed block, leaving any unrelated keys the user added intact.

§Idempotent marker

Every managed block has a sentinel key:

"// ai-memory:managed-block:start": "Do not edit. Managed by `ai-memory install`. https://github.com/alphaonedev/ai-memory-mcp/issues/487"

plus an // ai-memory:managed-block:end sibling. When present, the installer recognises the existing block and:

  • On install: replaces it with the freshly-rendered block (so config bumps in future ai-memory releases land cleanly).
  • On uninstall: removes both sentinel keys and any siblings the installer originally inserted.

§Targets

See Target for the full list. Each target’s specifics (config path discovery, JSON shape) live in apply_target_* helpers.

Structs§

InstallArgs
Args for ai-memory install.
TargetArgs
Shared per-target args. Constructed identically for every target so the dispatch table can pull them out generically.

Enums§

HookKind
Harness-side hook variant selectable via --hook <kind>. Today only Pretool is wired; future variants (e.g. PostToolUse, Stop) plug into the same dispatch shape.
Target
Concrete target enum used internally. TargetCmd carries clap metadata; Target is a stable tag for the dispatch table and derives ValueEnum for completeness.
TargetCmd
Per-target subcommand. Each variant carries the same shared option set (--apply, --uninstall, --config <path>) — clap-derive renders one subcommand per target so users get tab-completion on the agent name and per-target --help.

Functions§

run
ai-memory install <agent> entry point.