firefly v0.5.0

Documentation

Everything you need to install firefly, connect your agents and understand what they do with it.

What firefly is

firefly is persistent memory for AI agents. firefly is the app you install. A firefly is one memory inside it.

A firefly is an independent memory carrier. It holds one memory and serves it to whichever agents connect to it. It belongs to no agent and no session: it is there before an agent connects and after the agent leaves.

  • One firefly can serve many agents. Every agent connected to the same firefly reads and saves the same memory, so what one saves, the others can find.
  • One firefly can serve one agent. Connect a single agent to a firefly of its own and the firefly carries that agent's memory from session to session.

A firefly's memory is a folder of plain markdown files on your computer. Agents reach it over MCP. For each task an agent reads only the few memories that task needs, however much has been saved. A live map in your browser shows every memory and what each agent is reading and changing.

Every install starts with one firefly, named firefly. You can add more: see Several fireflies.

Install

You need Node.js 20 or newer.

  1. Get firefly

    -g installs it for your whole computer, so the firefly command works in any folder.

    npm install -g firefly-memory
  2. Start it

    firefly creates its memory folder at ~/.firefly and opens the map at http://localhost:7077. Leave the terminal window open: firefly has to be running for agents to reach their memory.

    firefly

Update

Then restart firefly. Your memories are not touched.

npm update -g firefly-memory

In one folder only

npm i firefly-memory, without -g, installs firefly into the folder you run it in. There is then no firefly command: in that folder, start it with npx firefly, use npx firefly in place of firefly in the commands below, and update with npm update firefly-memory.

npm i firefly-memory npx firefly

Connect an agent

firefly works with any agent that speaks MCP. Add it to the agent as an MCP server of type HTTP at this address, then start a new session in the agent.

http://localhost:7077/mcp/firefly

Many agents take a config block instead of an address:

{ "mcpServers": { "firefly": { "type": "http", "url": "http://localhost:7077/mcp/firefly" } } }

The Connected or Disconnected button on the map shows the address, this config block, and the sessions connected right now. Its header counts them, as in "2 connections".

The connection panel on the firefly map, showing the address, a config block to copy and the connected sessions.

That is all the setup there is. When an agent connects, the firefly sends it core: the rules for using firefly, and the standing rules and facts that firefly holds. You do not need to instruct the agent yourself.

Share one memory across agents

Connect each agent to the same address. They are then served by the same firefly: what one saves, the others can find.

Give an agent its own memory

Add another firefly and connect that agent to its address instead. See Several fireflies.

Move an agent's old memory in

If your agent already remembers things somewhere else, ask it to move them: “Move everything you remember about me and my work into firefly, one topic per memory, and tell me what you moved.” Then turn off the agent's old memory, so it remembers from one place.

Use it

Talk to your agent as usual. You never call firefly's tools yourself.

You sayThe agent does
“Remember that we deploy every Friday”Saves a new memory, or changes the one it already has on the topic
“What do you know about our deploys?”Calls enlighten with what it is looking for, and gets back the memory that fits
“Forget the old deploy schedule”Deletes that memory, which goes to the trash
“Undo that”Rewinds the most recent change
“Tidy up your memory”Reviews the whole memory and groups what belongs together

The agent also saves without being told to: when you state a fact about yourself or your work, say how it should work, make a decision, or correct it.

What happens in a session

  1. The agent connects

    When a session starts, the agent's program connects to every MCP server it has been given, firefly among them. This is automatic. Neither you nor the agent asks for it.

  2. The firefly sends core

    In its answer to the connection, the firefly sends core. The agent's program places it in the agent's instructions for the session. This happens once, at the start. Nothing is loaded again before each reply.

  3. The agent does its own thing

    From here firefly only answers. The agent decides when to look something up and when to save, following the rules in core. firefly sends no reminders and adds nothing to replies, with one exception: when a change leaves something to tidy, the reply to that change says so. See How memory stays tidy.

Core is read when the session connects. If another agent changes core while a session is running, that session keeps the core it was sent, and gets the new one the next time it connects.

Most agent programs pass a server's instructions to the agent. For one that does not, the enlighten tool says in its own description to read CORE.md first.

How memory is laid out

A firefly's memory has two parts: core, and a folder named peripheral that holds everything else.

~/.firefly/
├── memory/
│   ├── CORE.md         this firefly's standing rules and facts
│   └── peripheral/     every other memory, one topic per file
│       ├── peripheral.md     what is in peripheral, with a link to each
│       ├── example_folder/
│       │   ├── example_folder.md   what the folder holds
│       │   └── example_memory.md
│       └── example_memory.md
├── activity-log.md     everything that has happened
├── trash/              deleted memories and fireflies, kept for a month
├── rewind/             the last 5 changes, each file as it was before
├── search.json         what search by meaning knows of each memory
├── models/             the small model search by meaning uses
└── fireflies/          any further fireflies you add
  • Core is sent to every session. It is for what almost every session needs.
  • Peripheral is read only when a task needs it. Each memory is one markdown file on one topic.
  • Every folder has its own memory, named after it and kept inside it: example_folder/example_folder.md. It says what the folder holds and links to what is inside, one line each. It is a memory like any other: it can be found, linked to and edited. firefly adds a line when a memory is saved there, and takes it out when the memory is moved or deleted.
  • Memories can link to each other by writing [[name]] in their text. The map draws each link as a dotted line. When an agent reads a memory, firefly adds where its links lead and which memories link to it, as paths the agent can read next. That note is not part of the memory and is never saved with it.

There is nothing above peripheral. An agent starts with core, which it already has, and asks firefly for anything else when it needs it.

The files are plain markdown. You can open and back them up like any other folder, but make changes on the map rather than in the files, so that folders and links stay correct.

Core

Core is the one thing a firefly sends when an agent connects. It has two parts, in this order.

1. firefly's built-in block

The rules for using firefly: that firefly is the agent's only memory, how to find a memory, and how to save one. It is the same in every firefly. firefly supplies it; it is not stored in your memory folder and cannot be edited by an agent or on the map. This is its full text:

# firefly
firefly is your memory, and your only one. Do not use any other memory or notes in this session.

This is core.md, a standing set of rules and information that you must keep in mind and follow strictly.

## Finding a memory
Do this before you answer anything about the user, their work or an earlier conversation.

1. Call enlighten("what you are looking for"). You get the memory or folder that best fits, its path, and the way firefly found it.
2. Memories can link to other memories with [[links]], and a folder's memory links to what is inside it. To read one, call enlighten() with its path.
3. Nothing came back? Nothing is saved on this. Say so. Do not guess.

## Saving a memory
Do this before you reply, whenever the user gives a fact, a preference, a decision or a correction.

1. Decide where it belongs.
   - Core: something needed in almost every session. Call modify("CORE.md", old_text, new_text), as in step 3, on the part under "Standing rules and facts" below.
   - Anything else goes in peripheral. Go on to step 2.
2. Look for a memory on this topic, using "Finding a memory".
3. One exists: call modify(path, old_text, new_text). old_text is the exact text to change, copied from what you just read; new_text goes in its place.
   - To add: leave old_text empty, and new_text goes at the end.
   - To delete: leave new_text empty.
4. None exists: call write(path, content).
   - path: the folder that fits, then a short name, such as "peripheral/example_folder/example_memory.md". No folder fits: "peripheral/example_memory.md".
   - content: the fact in full sentences, with the date and who said it. One topic per memory.
5. Never save the same fact in two places.

## Always
- When a firefly reply says "To do", do it in the same turn.
- Only change memory through firefly's tools, never by editing its files.

2. Standing rules and facts

What this firefly holds for every session: who the user is, how the agent should work, and facts needed almost every time. This part is stored in CORE.md. It follows the block under the heading “Standing rules and facts”. A new firefly's reads “Nothing saved yet.”

An agent changes it with modify("CORE.md", old_text, new_text), like any other memory. Only the part under that heading can change. You can change it on the map by opening CORE.md.

Core is sent in full to every session, so it should stay short. When the stored part passes about 400 words, firefly asks the agent to move the detail into memories in peripheral.

Finding and saving

Finding a memory

The agent calls enlighten with what it is looking for, in a few words: enlighten("deploy schedule"). Reading a memory is called enlightening it. firefly finds the memory or folder that best fits and sends it back in the same reply, with its path and the way it got there:

Memory: peripheral/work/deploys.md
Found by: peripheral/ → peripheral/work/ → peripheral/work/deploys.md

# Deploys
Production deploys happen Tuesdays and Thursdays; never on Fridays.

If nothing fits, the reply says nothing is saved on the subject, and the agent says so instead of guessing. A word that is in no memory is named in the reply.

The agent can also give a path, such as enlighten("peripheral/work/deploys.md"), to read that memory. A folder's path returns the folder's own memory. A path that leads nowhere returns the closest memory, and says that the path itself does not exist.

How firefly gets there

firefly searches the way an agent would walk the folders, one layer at a time:

  1. In peripheral, it looks at the memories there and at each folder, and picks the one that fits best. A folder counts as well as the best thing inside it, so a short folder description cannot hide a strong match below.
  2. A memory ends the walk. For a folder, it looks inside and does the same again.
  3. When several things inside a folder fit about equally, the question is about the folder as a whole, so the walk stops there and sends the folder's own memory. Its links lead to what is inside. “Tell me about my family” stops at the family folder; “when is mom's birthday” goes on to the memory about mom.
  4. If another path came close, the reply names it under “Also close”, so the agent can read it if the first is not what it needed.

Each memory is scored two ways at once:

  • By words. A rare word counts for more than a common one, and little words such as “what” and “the” are ignored. Other forms of a word count too: “memories” finds “memory”, “deploy” finds “deployment”. A memory that holds only one of several words asked counts for less.
  • By meaning. A small model that runs inside firefly finds memories that mean the same thing in other words, so “who is he dating” finds a memory that only says “girlfriend”. It reads memory on your computer and sends nothing anywhere.

Each way backs the other up: a memory found by meaning alone must be close in meaning, and one found by words alone must hold most of the words asked.

Search by meaning uses all-MiniLM-L6-v2, about 23 MB, downloaded once from Hugging Face the first time firefly starts and kept in models/. firefly works out what each memory means when it starts and again after each change, and keeps it in search.json. If the model cannot be loaded, for example with no internet on the first start, firefly finds memories by words alone until it can.

Links

A memory that links to others shows the agent where those links lead, so related memories are one step away. Below the memory the agent reads:

Not part of the memory, added by firefly:
Links to: peripheral/example_folder/example_memory.md
Linked from: peripheral/example_memory.md

A folder's own memory reads with each link as a path to call next:

# Example folder
What this folder holds.

peripheral/example_folder/example_memory.md — what the memory holds
peripheral/example_folder/inner/ — what the folder inside holds

Anything in the folder that its memory does not link to is listed after it, so nothing is out of reach. Everything off the path stays unread, so memory can grow without each task costing more.

Saving a memory

The agent saves before it replies, whenever you give it a fact, a preference, a decision or a correction.

  1. If almost every session needs it, it goes in core.
  2. Otherwise the agent looks for a memory on the topic, as above.
  3. If one exists, the agent calls modify with the text to change and what goes in its place. The rest of the memory stays as it was.
  4. If none exists, the agent calls write with a path and the content. firefly links it from the folder's memory, using the memory's heading. A new folder gets its own memory, and firefly asks the agent to say what the folder holds.

The same fact is never saved in two places.

The agent's tools

The agent touches memory only through these seven tools, which is how the map sees everything it does.

ToolWhat it does
enlighten(what)Recall what the agent is looking for, given in a few words: firefly finds the memory or folder that fits best and returns it with its path. Or read the memory at a path. A memory comes with where its links lead and what links to it. enlighten("CORE.md") returns core as it was sent on connecting
write(path, content)Make a new memory. firefly links it from its folder's memory and creates the folder if it is new. A path that already holds a memory is refused, with a pointer to modify. A path outside peripheral is placed inside it
modify(path, old_text, new_text)Change part of a memory that exists, and leave the rest as it was. old_text is the exact text to change, copied from the memory: part of a line, a line or several lines. new_text goes in its place. An empty new_text deletes; an empty old_text adds new_text at the end. To add in the middle, copy the line it should follow into old_text and put it back, with the new line after it, in new_text. old_text must appear once: if it appears twice, or not at all, nothing changes and firefly says why, showing the closest line. Spacing at the ends of lines does not have to match, and a folder memory's links can be copied as enlighten shows them. Works on core too, on the part under “Standing rules and facts”. The reply gives the size before and after. A path with no memory is refused, with a pointer to write
delete(path)Remove a memory. It goes to the trash. firefly removes its line from its folder's memory and names any memory that still links to it. Core and peripheral cannot be deleted; any other folder can, once it is empty
move(from, to)Move or rename a memory. firefly updates both folders' memories and rewrites every link the move would break: links to the memory, and any other link whose name the new one would make fit two memories
review()Look over the whole memory in one call, to sort it
rewind(steps)List the most recent changes, or take back that many

Agents have no tools for adding, renaming or deleting fireflies. Those are yours: on the map, or with a command.

How memory stays tidy

firefly never reorganises memory itself. It tells the agent what needs doing, and the agent does it. It asks only in the reply to a change, never in the reply to a read. Each request begins “To do”, and core tells the agent to do it in the same turn.

  • Memory is sorted. After every ten new memories, firefly asks the agent to review the whole memory and group what naturally belongs together into folders. Unrelated memories stay where they are.
  • Memories stay short. A memory is read whole, so a long one costs its full length every time. When a memory passes about 400 words, firefly tells the agent to split it into separate memories in the same folder, so a task reads only the part it needs.
  • Folder memories stay short. When a folder's own memory passes about 100 words, firefly tells the agent to make subfolders and move memories into them. A new memory is never turned away because a folder is full.
  • Core stays short. When the stored part of core passes about 400 words, firefly tells the agent to move its detail into peripheral.
  • Links are kept working. When a memory or folder is moved or renamed, by an agent or on the map, firefly rewrites the links it would break. When a memory is deleted, firefly tells the agent which links now lead nowhere, and the agent repoints or removes them.

The map

The map is the page firefly opens at http://localhost:7077. It shows the memory live, and you can do everything there that the agent can.

The firefly map in a browser. Memories appear as dots joined by lines. A trail of amber dots shows the path the agent took, with the activity log beside it.
You seeIt means
A grey dotA memory
A rounded squareA folder
The dot named CORECore, where the map begins. peripheral hangs from it
An amber pathAn agent just read that memory. The path to it glows for a few seconds, then fades
A green flashA memory was just written or changed
Glowing white dots and lines while you hoverThe lines of the dot under the pointer, and the memories it links to

Click a dot to open that memory in its own tab. The pencil edits it, the arrow moves or renames it, and the bin deletes it. A folder's tab does the same for the folder and everything in it, and its plus makes a new memory in the folder: give it a name. The CORE tab shows the part of core this firefly stores, its standing rules and facts, and the pencil edits it. Below a memory, “Linked from” lists the memories that link to it.

While you edit:

  • Write, Split or Preview shows the text, the text beside how it reads, or only how it reads. Links in the preview work as you type them.
  • Typing [[ lists the memories you can link to. Pick one with the arrow keys and Enter, or click it.
  • Enter in a list starts the next item; Enter on an empty item ends the list. Tab indents.
  • ⌘S or Ctrl+S saves, and Esc stops editing. The word count shows how close the memory is to the length at which firefly asks agents to split it.
  • Nothing is lost by accident. Closing the tab, or leaving the page, with unsaved changes asks first. If an agent changes the memory while you edit it, the tab says so and lets you load the new version or keep yours.
A memory open in its own tab on the firefly map, being edited.

The Activity tab lists everything that has happened and who did it: an agent, you, or an edit made outside firefly. The same list is kept in activity-log.md.

When an agent looks for something with enlighten, its entry shows what it asked and where firefly landed. Click Show how it was found to see each step: the folder firefly looked in, the best few memories and folders there with their scores (the one picked is outlined), and why it went deeper or stopped. A score adds how well the words match and how well the meaning matches, up to 1 each. Click any name to open it. The steps are kept in the log too, so they are still there after firefly restarts.

Several fireflies

One install can hold several fireflies. Each is an independent memory carrier: its own core, its own peripheral, its own address. Agents connected to the same firefly share its memory; agents on different fireflies share nothing.

How you divide them is up to you. One firefly can serve every agent you use. Or an agent can have a firefly to itself, which then carries that agent's memory across its sessions.

The one every install starts with is named firefly. It cannot be renamed or deleted.

The list of fireflies on the map, each with its memory count, connected agents and address, a pencil to rename it and a bin to delete it.

You can add, rename and delete fireflies in two ways:

  • On the map, with the button at the top right.
  • With a command. See Commands.

Agents cannot add, rename or delete fireflies.

A firefly's address follows its name:

http://localhost:7077/mcp/new_firefly_name

Renaming a firefly changes its address, so reconnect its agents afterwards.

Undo and recover

Rewind

Rewind is the quick undo for recent mistakes. Every change made through firefly, by an agent or by you on the map, is kept in rewind/ with each file as it was before. The last 5 changes are kept. The Rewind button at the top right of the map lists them; rewinding to one takes back it and every change after it. The agent can do the same when you ask it to undo something.

Trash

The trash is the long-term safety net for deletes. A deleted memory, folder or firefly is moved to trash/ with the date in its name. To bring it back, move it out again. The trash is emptied every month: anything that has been there longer than 30 days is removed for good.

Commands

For firefly installed with -g. Installed in one folder only, run them in that folder with npx firefly in place of firefly, such as npx firefly list, and update with npm update firefly-memory. firefly's own messages always show the commands for how it was installed.

CommandWhat it does
fireflyStart firefly and open the map
Ctrl+CStop firefly
npm update -g firefly-memoryUpdate to the latest version. Your memories are not touched. Restart firefly afterwards
firefly add new_firefly_nameAdd a firefly: a separate memory with its own address
firefly rename firefly_name new_firefly_nameRename a firefly. Its address changes with its name
firefly delete firefly_nameDelete a firefly. Its folder goes to the trash
firefly listList the fireflies on this device and their addresses
firefly --port 8080Start on a different port. Addresses change with the port
firefly --dir path/to/folderStart with firefly's folder somewhere other than ~/.firefly
firefly --no-openStart without opening the browser
firefly initCreate firefly's folder and starter memory without starting it
firefly --versionShow which version is installed
firefly --helpShow this list in the terminal

Privacy

  • Memory stays on your computer, as plain markdown files in ~/.firefly. There are no accounts and no API keys.
  • firefly answers only on your own computer, at localhost.
  • The one thing firefly sends out is a count of how many memories were read, which is added to the worldwide counter on the home page. Nothing about what the memories say is sent: no content, names or paths.
  • The first time it starts, firefly downloads the model for search by meaning from Hugging Face. That is a download only. The model then runs on your computer, and memory never leaves it.

Updating from before 0.5.0

Version 0.5.0 changed how agents change a memory. Update and restart as usual; your memories are kept.

  • modify changes part of a memory, not all of it. It takes old_text and new_text instead of the memory's full new text, so an agent that sends only the new fact can no longer wipe the rest.
  • Start a new session in each agent after updating, so it is sent the new core and tool list. A program that calls modify with content needs to send old_text and new_text instead.
  • On the map, editing a memory still saves its whole text, as before.

Updating from before 0.4.0

Version 0.4.0 changed how agents find memories. Update and restart as usual; your memories are kept. This is what changes:

  • Each folder's INDEX.md becomes the folder's own memory. When firefly starts, peripheral/INDEX.md becomes peripheral/peripheral.md, and so on for every folder, with every line kept. If a memory with the folder's name was already there, it becomes the folder's memory and the old list is added at its end, under “In this folder”.
  • search is gone. enlighten takes what the agent is looking for and returns the memory itself, so finding a memory is one call instead of several.
  • write takes no summary. firefly links a new memory from its folder's memory using the memory's own heading.
  • Start a new session in each agent after updating, so it is sent the new core. An agent program that keeps its own copy of the tool list needs to refresh it.

Updating from before 0.3.0

Version 0.3.0 changed how agents use firefly. Update and restart as usual; your memories are kept. This is what changes:

  • The top-level INDEX.md is retired. When firefly starts, it moves that file from each firefly's memory to trash/. Nothing else is moved. Folder lists inside peripheral stay as they are.
  • Your CORE.md is kept as it is and becomes the “Standing rules and facts” part of core. A “# Core” title at its top is no longer shown.
  • Agents no longer load anything before each reply. Core arrives once, on connecting.
  • write only makes new memories, and modify takes a memory's full new text. Before, write could replace a memory and modify swapped one piece of text for another.
  • Four agent tools are gone: link, list_fireflies, add_firefly and delete_firefly. Agents link memories by writing [[name]] in a memory's text. You manage fireflies on the map or with a command.
  • Start a new session in each agent after updating, so it connects again and is sent core.

If you wrote your own program that calls firefly's tools, change any write to an existing path into a modify, and stop reading INDEX.md at the top of the memory. enlighten("INDEX.md") still answers, with the list in peripheral.

If something is wrong

What you seeWhat to do
“Port 7077 is already in use”firefly is already running in another window. Use that one, or start this one on another port with --port
The map says Disconnected while your agent is openCheck that firefly is running, then start a new session in the agent
The agent does not remember somethingLook on the map for whether it was saved. If it was, start a new session so the agent connects again and is sent core
The agent stopped working after a rename or a new portThe address changed. Give the agent the new address and start a new session

For anything else, open an issue on GitHub. What changed in each version is in the change log.