Skip to content

refactor(chat): replace remark with Comark - #1

Draft
onmax wants to merge 6 commits into
mainfrom
spike/comark
Draft

onmax wants to merge 6 commits into
mainfrom
spike/comark

Conversation

@onmax

@onmax onmax commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

Summary

chat parses every message with unified/remark, which pulls 71 packages into its production dependencies and needs 333 lines of input guards to stay fast on hostile messages. this is a spike to measure what goes away with Comark. it isn't meant to merge.

this swaps remark for Comark in chat and every adapter, installed from the pkg.pr.new build of comarkdown/comark#529, which reads frontmatter with tinyaml instead of js-yaml. chat drops to 13 production dependencies.

added removed net
source 1,609 1,929 −320
tests 3,353 5,156 −1,803

parsing and rendering get 5.5 to 17 times faster. median of 5 rounds per call, Apple M4, Node 26.13. medium is a 652-character LLM-style reply.

operation remark Comark speedup
parseMarkdown medium 307.1 µs 21.4 µs 14.4x
stringifyMarkdown medium 104.7 µs 18.0 µs 5.8x
teams fromMarkdown medium 325.6 µs 27.3 µs 11.9x
discord fromMarkdown medium 315.8 µs 37.8 µs 8.3x
telegram fromMarkdown medium 415.4 µs 29.8 µs 13.9x
slack parseIncoming mrkdwn 147.5 µs 13.2 µs 11.2x
streaming render, 12-char chunks 425.8 µs 44.9 µs 9.5x

bundles grow, mostly because markdown-exit and Comark each bring their own version of entities (62 KiB together). esbuild 0.28, minified ESM, KiB minified / gzip.

entry remark Comark gzip change
parser libraries only 158.8 / 48.4 214.3 / 93.6 +93%
chat, whole package 266.6 / 77.2 320.6 / 121.7 +58%
@chat-adapter/telegram 279.8 / 82.8 333.0 / 127.1 +54%
@chat-adapter/slack 695.1 / 192.6 748.7 / 236.9 +23%

Test plan

pnpm knip, pnpm check, and turbo typecheck test pass for every package (79 tasks), integration tests included. node scripts/bench-markdown.mjs <repo-root> <label> reproduces the timings.

Checklist

  • All commits are signed and verified
  • All commits are signed off for the DCO (git commit -s)
  • pnpm validate passes
  • Changeset added (or N/A — see CONTRIBUTING.md)
  • Documentation updated (or N/A)

onmax and others added 4 commits October 31, 2026 08:53
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@onmax onmax changed the title spike: replace remark with Comark replace remark with Comark Oct 31, 2026
onmax and others added 2 commits November 2, 2026 11:12
comarkdown/comark#529 replaces js-yaml with tinyaml.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drop async and await the port added to tests that never wait, a
one-caller GitLab wrapper, Twilio's structuredClone (walkAst returns a
copy), and a chat test that re-tested the plain nested-list path after
the HTML branch went away. Rename tests that only check serialization,
and keep the benchmark script out of knip.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: onmax <maximogarciamtnez@gmail.com>
@onmax onmax changed the title replace remark with Comark refactor(chat): replace remark with Comark Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant