Built-ins

memory Plugin

Agent long-term memory plugin backed by an LLM Wiki structure

memory Plugin

memory is the agent long-term memory plugin. It exposes memory capabilities to the agent while organizing durable knowledge as an LLM Wiki internally.

It provides:

  • memory wiki search
  • memory wiki reads
  • explicit facts, preferences, and decisions
  • session-to-wiki digest
  • wiki page revision with new evidence
  • memory system text

Main Shape

  • lifecycle
  • actions
  • system

Storage Shape

.downcity/memory/
  wiki/       # curated knowledge layer primarily read by agents
  sources/    # raw evidence from sessions and manual inputs

wiki/ is the main long-term memory surface. sources/ is evidence and rebuild material. Search defaults to the wiki layer; include sources only when evidence is needed.

Constructor Injection

LLM digest/revise capabilities are passed through the constructor:

import { MemoryPlugin } from "@downcity/plugins";

const memory = new MemoryPlugin({
  digest: async (input) => {
    return {
      pages: [
        {
          path: "project-decisions.md",
          title: "Project Decisions",
          content: "Compiled wiki markdown",
        },
      ],
      summary: "Updated project decisions.",
    };
  },
  revise: async (input) => {
    return {
      path: input.path,
      content: "Full revised wiki markdown",
    };
  },
});

If digest or revise is not provided, the plugin falls back to deterministic behavior: archive the source and append to wiki pages without calling a model.

How Users Use It

Use the downcity memory shortcut for normal local operation:

downcity memory status
downcity memory search "project decision" --max-results 5
downcity memory read .downcity/memory/wiki/project-decisions.md --from 1 --lines 20
downcity memory remember --content "Prefer constructor-based plugin config." --topic "plugin system"
downcity memory digest --session-id <sessionId> --max-messages 30
downcity memory revise .downcity/memory/wiki/plugin-system.md --instruction "Merge the latest constructor config decision"

SDK Action Use

await agent.plugins.runAction({
  plugin: "memory",
  action: "remember",
  payload: {
    content: "User preference: plugin config is passed through constructors.",
    topic: "plugin system",
  },
});

The action names are status, search, read, remember, digest, and revise.

Important Semantics

  • MemoryPlugin is LLM Wiki style memory, not a vector database.
  • wiki/ is the primary durable knowledge layer for agents.
  • sources/ is evidence and is excluded from search unless includeSources is set.
  • LLM capabilities are injected through the constructor, not read from project config files.
  • Memory enablement is separate from whether the plugin exists in code.