# MiMo Code

> Import MiMo Code sessions from its local SQLite database, without copying account or credential data.

MiMo Code is based on OpenCode, but it stores its history in its own SQLite
database with a different layout. Hansard imports it as a separate source.

## Source IDs

| Source      | Use it for                                                        |
| ----------- | ----------------------------------------------------------------- |
| `mimo-code` | MiMo Code sessions from `mimocode.db` in MiMo Code's data folder. |

## How the import works

Hansard finds `mimocode.db` in MiMo Code's data folder, which is
`$XDG_DATA_HOME/mimocode` (normally `~/.local/share/mimocode`) by default. An
absolute `MIMOCODE_HOME` moves it to `<MIMOCODE_HOME>/data`; a relative value
is ignored. `MIMOCODE_DB` can name an absolute path or a file name inside the
data folder, and `:memory:` is ignored. To point Hansard somewhere else, set
`HANSARD_MIMO_CODE_DATA_DIR` or `HANSARD_MIMO_CODE_DB`.

Before reading anything, Hansard takes a consistent copy of the database,
including changes that are still in its write-ahead log. It then makes a
history-only copy that leaves out account, credential, and share-secret
tables. Hansard checks the session, message, and part tables and makes sure
every record is accounted for. It then converts text, reasoning, tool calls
and results, attachments, model and usage details, and agent links. The
archive keeps the history-only copy, never your live database.
Snapshot replay retains the same native conversation, parent, and nested
actor identities as live import.

MiMo Code's database differs from OpenCode's: it adds context and checkpoint
columns and agent IDs, has no full-message table, and stores todos
differently. Hansard does not import MiMo Code's older JSON migration files as
a second history. If the database contains unknown, mixed, damaged, or
incomplete records, Hansard stops the import instead of importing part of the
history.

## Import and keep current

**Import now**

```sh
hansard import --source mimo-code --since all
hansard index rebuild
```

**Keep current**

With **Automatic** source selection, the watcher already includes
`mimo-code`. With a **Custom** list, enable it. The watcher picks it up within 30 seconds:

```sh
hansard config sources enable mimo-code
```

## Review the import in the app

1. When the import finishes, open **Conversations** and select **Filter & sort**.
2. Set **Source** to **MiMo Code** and set **Time** to the window you imported. Use **Folder** to narrow the list when you use this harness in several projects.
3. Select a conversation to check its messages, tool calls, files, commits, model, and token usage.

To keep archiving new sessions from a local harness, open **Settings → Imports**. **Automatic** follows every supported harness installed on this computer. **Custom** lets you turn individual harnesses on or off. Cloud sources and account exports never run from here; each needs its own import command. If a conversation you expect is missing after you reset the filters, run the import command on this page again with `--explain-skips` where the source supports it.

## What Hansard preserves

- Sessions, messages, parts, tool calls and results, attachments, model and
  usage details, workspace details, current todos in order, and linked agent
  sessions.
- Session titles with where each title came from, prompt configuration, each
  agent's result message, and the system and tool prompt prefixes that MiMo
  Code 0.1.15 records.
- The history-only copy of the database used for the import, including
  changes that were still in its write-ahead log. Account, credential, and
  share-secret tables are left out.

## Known limitations

- After rebuilding a SQLite snapshot from raw, ordinary live imports cannot
  overwrite that snapshot. Returning to live imports currently requires a full
  archive refresh. Preview `hansard update --dry-run` before choosing its scope.
- MiMo Code shares OpenCode's origins, but Hansard never reads its database as
  an OpenCode database.
- Pricing for a specific model route needs the exact route recorded in MiMo
  Code's database.
- Unknown or damaged records stop the import instead of being silently left
  out.

> **OpenCode is a separate source:** OpenCode uses `opencode.db` and MiMo Code uses `mimocode.db`. Hansard never
> reads one tool's folder while importing the other. See
> [OpenCode](https://www.hansard.dev/imports/opencode/).

## Refresh an existing archive

```sh
hansard import --source mimo-code --since all
hansard index rebuild
```

After an update, the watcher refreshes most archived conversations on its own,
but it leaves MiMo Code's SQLite snapshots as they are. The import above reads
them again from MiMo Code's database. If that database is gone, rebuild the
snapshots from Hansard's preserved copy:

```sh
hansard rebuild --from-raw --source-type mimo-code-history --since all
```
