# CodeBuddy

> Import CodeBuddy Code project transcripts. Hansard counts and keeps any record types it does not recognize.

Hansard's CodeBuddy support is based on the published CodeBuddy Code package
through version 2.163.0 and has not yet been checked against a real CodeBuddy
history. It imports the
records it recognizes and counts the rest.

## Source IDs

| Source      | Use it for                                                                                                  |
| ----------- | ----------------------------------------------------------------------------------------------------------- |
| `codebuddy` | CodeBuddy Code project transcripts in `~/.codebuddy/projects`, their metadata files, and subagent sessions. |

## How the import works

Hansard scans CodeBuddy's project transcript folders and reads the record types
described in the published CodeBuddy package. It puts user and assistant
messages, reasoning, tool calls and results, and compaction records in the
order CodeBuddy saved them. The project comes from the working directory
recorded in the session, because CodeBuddy's folder names do not always map
back to the original path.

Metadata files can add the model, token usage, and links to subagent sessions.
When Hansard finds a record type it does not recognize, it counts the record
and keeps the original file instead of guessing a message from it. A later
Hansard update can then read more from the same original files after a
reimport, so the archive stays useful now without losing anything.

## Import and keep current

**Import now**

```sh
hansard import --source codebuddy --since all
hansard index rebuild
```

**Keep current**

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

```sh
hansard config sources enable codebuddy
```

## Review the import in the app

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

- User and assistant messages, reasoning, tool calls and results, and
  compaction records.
- Token usage for each message and linked subagent sessions.
- The working directory recorded in each session.
- A count of each record type Hansard did not recognize.

## Known limitations

- Support is based on the CodeBuddy package rather than real CodeBuddy
  histories. Every field is optional, and coverage may change.
- Records Hansard does not recognize are counted in the session's details but
  do not appear as messages.
- While CodeBuddy is still writing a session's last record, Hansard waits and
  imports the session once that record is complete. Sessions Hansard cannot
  read are reported in the import diagnostics.

> **Keep your CodeBuddy history:** Keep CodeBuddy's original files. A later Hansard update may need a full
> reimport to read records that are only counted today.

## Refresh an existing archive

```sh
hansard import --source codebuddy --since all
hansard index rebuild
```
