# Muse Code

> Import Muse Code sessions with their titles, models, tool calls, token usage, and linked subagent runs.

Muse Code writes one `session.jsonl` log per session under
`~/.local/share/muse/sessions`, or under `$XDG_DATA_HOME/muse/sessions` when
that variable is set. Hansard reads those logs and the subagent runs they start.

## Source IDs

| Source      | Use it for                                         |
| ----------- | -------------------------------------------------- |
| `muse-code` | Muse Code sessions and their linked subagent runs. |

## How the import works

Hansard reads each session log from start to finish and rebuilds the
conversation from its events. Session metadata sets the working folder, which
becomes the project, and the model the session started with. A renamed session
keeps its latest name as the title. Each run records the model it used, so a
session that switches models shows the model on every reply.

Each run's prompt becomes your message. Finished assistant replies, tool
calls, and tool output follow it; partial text streamed while Muse Code was
still writing is left out. The token usage Muse Code reports for each response
is attached to that reply.
When a workflow starts a child session, Hansard imports the child as a linked
subagent run and places its result in the parent conversation. Skill reads
count toward skill usage in Stats, and workflow calls count as delegation.
Hansard skips logs that change while it reads them or that exceed its size
limits, and importing again updates the same session.

## Import and keep current

**Import now**

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

**Keep current**

With **Automatic** source selection, the watcher already includes
`muse-code`. With a **Custom** list, enable it and restart the watcher:

```sh
hansard config sources enable muse-code
hansard watcher restart
```

## Review the import in the app

1. When the import finishes, open **Conversations** and select **Filter & sort**.
2. Set **Source** to **Muse 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

- Your prompts, finished assistant replies, tool calls, and tool output.
- The session title, working folder, model provider, and the model of every run.
- Input and output token counts for each response.
- Linked subagent runs started by workflows, with their results.
- An exact copy of each session log next to the conversation.

## Known limitations

- Hansard reads logs up to 64 MB, with lines up to 16 MB. Larger logs are
  skipped.
- A log that changes during the read is skipped and picked up on the next pass.
- Sessions stored outside the default folder need `HANSARD_MUSE_CODE_DIR` (the
  sessions folder) or `HANSARD_MUSE_CODE_HOME` (the Muse data folder).

## Refresh an existing archive

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