Husk
GitHub

Chat to bot

Importing a transcript

Claude Code, Codex, ChatGPT, Cursor, Gemini and markdown, normalised into one Transcript.

The conversation you had yesterday is a bot you can run today, and the first step is getting it out of whatever tool it happened in.

In the console, a Claude Code or Codex chat that used Husk has Make this a bot on its page: Husk reads the chat back itself. For any other chat, Husks › Make a bot from a chat finds the chats on this computer, or takes an export or pasted text, and shows the draft before anything is saved. At the terminal:

husk import

With no path, Husk searches the usual places, lists what it found, and asks you to choose:

husk import
FlagWhat it does
--source <s>Force an importer instead of detecting
--pick <n>Choose by number without being asked
--limit <n>How many candidates to list. Default 20
--jsonPrint the discovered list, or the imported transcript
husk import --pick 1
husk import ./chat.md --source markdown
husk import ~/.claude/projects/-home-me-api/4f2a91c3.jsonl

Imported transcripts are cached under ~/.husk/transcripts/ and get an id you can hand to husk distill.

The seven importers

SourceFormatWhere husk import looks
claude-codeJSONL event log~/.claude/projects/**/*.jsonl and ~/.config/claude/projects, or $CLAUDE_CONFIG_DIR/projects
codexOne JSONL rollout per session~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl, or $CODEX_HOME/sessions
chatgptconversations.json from a data exportconversations*.json in ~/Downloads and ~/Documents
cursorstate.vscdb, or an exported JSON/markdown chatThe platform's Cursor globalStorage directory, and JSON or JSONL under ~/.cursor
geminiCLI checkpoints, or a Takeout "My Activity" exportThe chats Gemini CLI saved, ~/.gemini/tmp/*/checkpoint-*.json. Pass a Takeout export's path
markdownA pasted conversation with role markers*.md in the current directory that parse as a chat
universalAnything else with role markers, read by the markdown heuristics~/Downloads/*chat*.json, and *.jsonl in the current directory

The console's Make a bot from a chat looks elsewhere: Claude Code's ~/.claude/projects and ~/.config/claude/projects, Codex's sessions, Cursor's state.vscdb and ~/.gemini/tmp. It lists no ChatGPT export, so give it that one as a file.

A Codex rollout carries Codex's own context beside the chat: the environment, AGENTS.md, permission notes. The importer keeps only what you and Codex said and the tools it called. A file that holds many chats, such as a ChatGPT export or Cursor's state.vscdb, asks which one in the console; husk import keeps them all.

husk import and husk distill <path> read the whole file, and each importer scores it 0–1. The highest scorer that returns a transcript wins; one that throws or returns nothing hands over to the next. universal scores 0.05 on anything, so it wins only when nothing else recognised the file. --source skips detection, and a name with no importer fails with no importer for source "jsonl", its hint listing the ones there are. The console takes the highest scorer and tries no other. detectAndParse() in @husk-ai/sessions sniffs only the first 32 KB, but neither command calls it.

Branches

Both Claude Code and ChatGPT store a conversation as a tree, not a list, because retrying a turn forks it. Husk reconstructs the branch you actually kept.

Claude Code: nodes link through parentUuid. Husk finds every leaf, walks each one back to the root, and takes the longest chain, breaking ties by the later leaf timestamp. A retried turn abandons its branch, and the branch you kept going down is the longer one. Cycles are guarded with a seen-set.

ChatGPT: the export names a current_node. Husk walks parent links back from it and reverses. When current_node is missing or dangling, it falls back to the deepest leaf.

The result is the conversation as it ran, not every dead end.

What gets dropped, and why

Claude Code transcripts carry a lot that is not conversation:

DroppedKept as
thinking and redacted_thinking blocksA count in the transcript's meta.thinkingBlocks, and on the message they came with, when there is one
Sidechain nodes (isSidechain: true)Their tool names, in meta.sidechainTools
isMeta nodes — injected images, loaded skill docs, hook outputNothing
Harness plumbing inside a turn — <system-reminder>, <task-notification>, <command-name> and their kinCut out, and a turn of nothing else is dropped: counts in meta.parse.scaffoldingStripped and meta.parse.scaffoldingDropped. A tool result is cut but never dropped, and code spans and fences are left alone
Unparseable JSONL linesA count in meta.parse.unparseable

A truncated final line is recorded as truncatedTail rather than counted as corruption, because an append-only log that is still being written always has one.

tool_use becomes an assistant message with the text [tool: <name>], plus toolName and toolInput. tool_result becomes a tool-role message, with its name resolved from a file-wide map of tool-use ids.

Husk also scans <dir>/<basename>/subagents/*.jsonl next to a Claude transcript and merges those tool names in, so a husk distilled from a session that used subagents knows which tools were really in play.

The Cursor caveat

Cursor stores chats in a SQLite database, and Husk has no SQLite driver — no native modules is a build-contract rule, not an oversight.

So the .vscdb path is a byte-level salvage: Husk scans for JSON objects whose first key is "composerId", "tabs", "conversation", "bubbles" or "richText", does a brace-depth scan that understands strings and escapes, and parses only the objects that come out balanced. An object split across a SQLite overflow page is dropped.

It never invents a partial conversation. It does silently recover less than everything.

The Transcript

Whatever the source, you get one shape:

interface Transcript {
  id: string;
  source: TranscriptSource;
  title?: string;
  createdAt?: string;
  updatedAt?: string;
  origin?: string;          // a file path, an export id, a URL
  messages: TranscriptMessage[];
  meta?: Record<string, unknown>;
}
 
interface TranscriptMessage {
  role: 'system' | 'user' | 'assistant' | 'tool';
  content: string;
  ts?: string;
  toolName?: string;        // set on a tool call or a tool result
  toolInput?: unknown;
  meta?: Record<string, unknown>;
}

Discovery caveats worth knowing

husk import with no path lists files, not conversations: a source, a title, a size and a date, newest first, with no message count, and nothing filters out a short chat. The scan stops at 400 files, skips anything over 64 MB, and offers a markdown file only when two role markers parse in its first 32 KB, so a repository's CHANGELOG.md is not mistaken for a chat.

The console's list reads each JSONL file whole and gives its non-empty lines as the message count; any other format shows 0. It takes up to 200 files from each place, three directories deep.

discover() in @husk-ai/sessions counts Claude Code messages from a 96 KB head-and-tail window and takes a minMessages filter. Neither the CLI nor the console calls it.

Redaction

Everything that leaves the importer can be run through redactTranscript, which scrubs three kinds of thing:

KindBecomes
Credentials — Anthropic, OpenAI, Groq, Google, GitHub, Slack, AWS, npm, Fly and xAI keys, Authorization header values, and PEM private keys[redacted], a header keeping its name and scheme (Authorization: Bearer [redacted]), or [redacted private key]
Home directories, yours or anyone's, in all their spellings~
Email addresses[email]

None of a key is kept, so a bot's name or file name cannot carry part of one. Logs and tool output go through core's redact() instead, which keeps a few characters to tell two keys apart: sk-ant...[redacted].

It covers message content, tool input, the title and the origin. It does not touch message.meta or transcript.meta, which for Claude Code includes meta.cwd — a full home path. That is not a leak into a husk.yaml, because toSpec does not copy it, but a redacted Transcript object still carries it.