@molecule/api-agent-transcript-markdown-chat
Provider bond · agent-transcript · API (Node) · v1.0.1 · Apache-2.0
A last-resort transcript reader for plain Markdown or text chats with clear User / Assistant speaker markers
npm install @molecule/api-agent-transcript-markdown-chatnpm · Source on GitHub · Implements @molecule/api-agent-transcript
How it works
@molecule/api-agent-transcript-markdown-chat is a provider bond on the API (Node) side: it implements the agent-transcript core interface (@molecule/api-agent-transcript) with a concrete vendor or library behind it.
Your code calls the core; you wire this provider once at startup. Swapping vendors later is one line in that wiring, not a rewrite.
import { readTranscript, setProvider } from '@molecule/api-agent-transcript'
import { provider } from '@molecule/api-agent-transcript-markdown-chat'
setProvider(provider)
const session = readTranscript({
text: '**User:** Add a README.\n\n**Assistant:** Added README.md with a short overview.',
fileName: 'chat.md',
})
// session.turns → [{ role: 'user', … }, { role: 'assistant', … }]Works with: @molecule/api-agent-transcript
Reference
Generic Markdown chat reader for @molecule/api-agent-transcript.
The reader of last resort: a plain Markdown or text chat whose turns start
with a speaker marker — a heading (## User / ## Assistant), a bold
label (**User:** …) or a plain label (User: …). Use it for chats saved
by hand, copied out of a chat web app, or written by a harness that has no
reader of its own.
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
Quick Start
import { readTranscript, setProvider } from '@molecule/api-agent-transcript'
import { provider } from '@molecule/api-agent-transcript-markdown-chat'
setProvider(provider)
const session = readTranscript({
text: '**User:** Add a README.\n\n**Assistant:** Added README.md with a short overview.',
fileName: 'chat.md',
})
// session.turns → [{ role: 'user', … }, { role: 'assistant', … }]
Type
provider
Installation
npm install @molecule/api-agent-transcript-markdown-chat @molecule/api-agent-transcript
API
Functions
chatStyleOf(text)
The marker style a text uses: the style of its first marker, provided the text has at least one user and one assistant marker in that style.
function chatStyleOf(text: string): Style | null
text— The text.
Returns: The style, or null when the text is not a chat.
looksLikeMarkdownChat(text)
Whether a text is a Markdown / plain-text chat.
function looksLikeMarkdownChat(text: string): boolean
text— The file's text.
Returns: True when it has user and assistant markers in one style.
readMarkdownChat(text)
Read a Markdown / plain-text chat.
function readMarkdownChat(text: string): AgentSession
text— The chat's text.
Returns: The normalized session.
Constants
USER_NAMES
Names that mark the person.
const USER_NAMES: readonly ['user', 'human', 'you', 'me']
ASSISTANT_NAMES
Names that mark the assistant.
const ASSISTANT_NAMES: readonly [
'assistant',
'ai',
'bot',
'model',
'agent',
'claude',
'chatgpt',
'gpt',
'gemini',
'copilot',
'cursor',
]
provider
Reads a plain Markdown or text chat with User / Assistant speaker markers. Compose it LAST: every harness-specific reader should get the first look.
const provider: AgentTranscriptReader
Core Interface
Implements @molecule/api-agent-transcript interface.
Bond Wiring
Setup function to register this provider with the core interface:
import { setProvider } from '@molecule/api-agent-transcript'
import { provider } from '@molecule/api-agent-transcript-markdown-chat'
export function setupAgentTranscriptMarkdownChat(): void {
setProvider(provider)
}
Injection Notes
Requirements
Peer dependencies:
@molecule/api-agent-transcript^1.0.0
Runtime Dependencies
-
@molecule/api-agent-transcript -
Compose it last.
@molecule/api-agent-transcript-autodetecttries every harness reader first; this one only sees files none of them claimed. -
It still refuses anything without at least one user marker AND one assistant marker, so a document that merely mentions "User:" is not a chat.
-
User names: User, Human, You, Me. Assistant names: Assistant, AI, Bot, Model, Agent, Claude, ChatGPT, GPT, Gemini, Copilot, Cursor. Case does not matter; a trailing colon is optional for headings.
-
Only the style of the file's first marker splits turns, and markers inside fenced code blocks are ignored — so a
Model:line in a reply does not break a chat written with##headings. -
A chat names no model, no times and no file writes; those fields stay empty.
harnessisMarkdown chat.