mirror of
https://github.com/hanzoai/bot.git
synced 2026-10-30 17:24:26 +00:00
Three coordinated things:
1. Resolve the committed upstream/main merge conflicts. 94 files were
sitting with raw <<<<<<< HEAD ... >>>>>>> upstream/main blocks. Every
conflict had HanzoBot/Bot on HEAD and OpenClaw on upstream. Resolved
by keeping HEAD everywhere — 540 conflict blocks.
2. Rewrite remaining OpenClaw text refs.
OPENCLAW → HANZO_BOT
OpenClaw → HanzoBot (PascalCase type identifiers)
openclaw → bot (codebase convention — botToken,
botUsername etc.; avoids invalid
hyphenated JS identifiers)
openclaw[_]/openclaw[A-Z] → bot[_]/bot[A-Z] (compound)
ai.openclaw.x → ai.hanzo.bot.x (JVM package path)
3. Delete or rename openclaw-named file paths (116 of them). Dead
duplicates with a Bot-named canonical from the partial migration:
deleted. Otherwise renamed.
ai/openclaw/** → deleted (ai/hanzo/bot/** canonical)
Sources/OpenClaw*/ → deleted (Sources/Bot* canonical)
Tests/OpenClawIPCTests/ → deleted (Tests/BotIPCTests canonical)
OpenClawKit/ → deleted (BotKit canonical)
openclaw-tools.*.ts → deleted (bot-tools.*.ts canonical)
openclaw-root.ts etc. → deleted (bot-root.ts canonical)
types.openclaw.ts → deleted (types.bot.ts canonical)
extensions/*/openclaw.plugin.json → renamed hanzo-bot.plugin.json
docs/start/openclaw.md → renamed hanzo-bot.md (+ zh-CN)
docs/assets/openclaw-*.png, whatsapp-openclaw*.jpg → deleted
scripts/.../openclaw-* → deleted (bot/hanzo-bot parallels)
openclaw.mjs → deleted (hanzo-bot.mjs is package.bin)
Then patched 65 broken JS/TS import strings where hanzo-bot had ended
up inside an import path ('./types.hanzo-bot.js' → './types.bot.js'
etc., since the on-disk filename uses the brand-neutral bot- prefix).
Pre-existing lint debt cleaned up to get oxlint --type-aware to 0/0:
removed the dead i18n test that referenced a path no longer existing;
defined the missing DIDConfig and WalletConfig types in types.base.ts
(they were imported but never declared); dropped unused imports;
collapsed redundant type assertion and a tautological meta.bot lookup
that the openclaw→bot rename made redundant.
The a2ui.bundle.js generated artifact is kept at its pre-rebrand
contents — it gets regenerated by 'pnpm canvas:a2ui:bundle' from
sources I cannot rebuild in this commit; the source side is clean.
Verified: 0 occurrences of openclaw (case-insensitive) in tree source
content, 0 file or directory paths with openclaw in the name; oxlint
--type-aware src test reports 0/0.
4.6 KiB
4.6 KiB
summary, read_when, title
| summary | read_when | title | |||
|---|---|---|---|---|---|
| Markdown formatting pipeline for outbound channels |
|
Markdown Formatting |
Markdown formatting
HanzoBot formats outbound Markdown by converting it into a shared intermediate representation (IR) before rendering channel-specific output. The IR keeps the source text intact while carrying style/link spans so chunking and rendering can stay consistent across channels.
Goals
- Consistency: one parse step, multiple renderers.
- Safe chunking: split text before rendering so inline formatting never breaks across chunks.
- Channel fit: map the same IR to Slack mrkdwn, Telegram HTML, and Signal style ranges without re-parsing Markdown.
Pipeline
- Parse Markdown -> IR
- IR is plain text plus style spans (bold/italic/strike/code/spoiler) and link spans.
- Offsets are UTF-16 code units so Signal style ranges align with its API.
- Tables are parsed only when a channel opts into table conversion.
- Chunk IR (format-first)
- Chunking happens on the IR text before rendering.
- Inline formatting does not split across chunks; spans are sliced per chunk.
- Render per channel
- Slack: mrkdwn tokens (bold/italic/strike/code), links as
<url|label>. - Telegram: HTML tags (
<b>,<i>,<s>,<code>,<pre><code>,<a href>). - Signal: plain text +
text-styleranges; links becomelabel (url)when label differs.
- Slack: mrkdwn tokens (bold/italic/strike/code), links as
IR example
Input Markdown:
Hello **world** — see [docs](https://docs.hanzo-bot.ai).
IR (schematic):
{
"text": "Hello world — see docs.",
"styles": [{ "start": 6, "end": 11, "style": "bold" }],
"links": [{ "start": 19, "end": 23, "href": "https://docs.hanzo-bot.ai" }]
}
Where it is used
- Slack, Telegram, and Signal outbound adapters render from the IR.
- Other channels (WhatsApp, iMessage, MS Teams, Discord) still use plain text or their own formatting rules, with Markdown table conversion applied before chunking when enabled.
Table handling
Markdown tables are not consistently supported across chat clients. Use
markdown.tables to control conversion per channel (and per account).
code: render tables as code blocks (default for most channels).bullets: convert each row into bullet points (default for Signal + WhatsApp).off: disable table parsing and conversion; raw table text passes through.
Config keys:
channels:
discord:
markdown:
tables: code
accounts:
work:
markdown:
tables: off
Chunking rules
- Chunk limits come from channel adapters/config and are applied to the IR text.
- Code fences are preserved as a single block with a trailing newline so channels render them correctly.
- List prefixes and blockquote prefixes are part of the IR text, so chunking does not split mid-prefix.
- Inline styles (bold/italic/strike/inline-code/spoiler) are never split across chunks; the renderer reopens styles inside each chunk.
If you need more on chunking behavior across channels, see Streaming + chunking.
Link policy
- Slack:
[label](url)-><url|label>; bare URLs remain bare. Autolink is disabled during parse to avoid double-linking. - Telegram:
[label](url)-><a href="url">label</a>(HTML parse mode). - Signal:
[label](url)->label (url)unless label matches the URL.
Spoilers
Spoiler markers (||spoiler||) are parsed only for Signal, where they map to
SPOILER style ranges. Other channels treat them as plain text.
How to add or update a channel formatter
- Parse once: use the shared
markdownToIR(...)helper with channel-appropriate options (autolink, heading style, blockquote prefix). - Render: implement a renderer with
renderMarkdownWithMarkers(...)and a style marker map (or Signal style ranges). - Chunk: call
chunkMarkdownIR(...)before rendering; render each chunk. - Wire adapter: update the channel outbound adapter to use the new chunker and renderer.
- Test: add or update format tests and an outbound delivery test if the channel uses chunking.
Common gotchas
- Slack angle-bracket tokens (
<@U123>,<#C123>,<https://...>) must be preserved; escape raw HTML safely. - Telegram HTML requires escaping text outside tags to avoid broken markup.
- Signal style ranges depend on UTF-16 offsets; do not use code point offsets.
- Preserve trailing newlines for fenced code blocks so closing markers land on their own line.