The docmd 0.6.8 release is a foundational leap for the plugin ecosystem. It introduces a WebSocket RPC protocol that enables real-time browser-to-server communication, powerful source editing tools for manipulating markdown files from the browser, and a brand-new Threads plugin for inline discussion comments β all without adding any new runtime dependencies.
β¨ Highlights
π WebSocket RPC β Live Plugin Communication
The dev serverβs existing WebSocket connection (used for live-reload) has been upgraded with a JSON-based RPC protocol. Plugins can now register server-side action handlers that the browser can call in real-time. This opens the door to live-editing features, collaborative workflows, and interactive documentation tools.
A new window.docmd browser API is automatically injected during development, providing:
docmd.call(action, payload)β RPC calls with responsedocmd.send(name, data)β Fire-and-forget eventsdocmd.on(name, callback)β Subscribe to server-pushed eventsdocmd.afterReload()/docmd.scheduleReload()β State persistence across live reloads
π§° Source Editing Tools
A new source-tools utility provides block-level markdown manipulation from plugin code. It can locate text within blocks, wrap content with syntax markers, insert/replace/remove blocks β all with frontmatter-aware line tracking and path traversal protection.
π§΅ Threads Plugin (Alpha)
Introducing @docmd/plugin-threads β inline discussion threads stored directly in your markdown files. Select text, leave comments, reply, react with emoji, and resolve threads. No database needed β comments are the source of truth in the .md files.
π€ Parser Export
The createDepthTrackingContainer function is now exported from @docmd/parser, allowing external plugins to register custom ::: container syntax with proper nesting support.
π Complete Changelog
π Plugin API
- WebSocket RPC Protocol: JSON-based message handling alongside the existing
reloadstring protocol for full backward compatibility. - Action Dispatcher: Routes incoming RPC calls to registered plugin action handlers with a sandboxed
ActionContext. - Plugin Hooks Expansion: Plugins can now export
actionsandeventsobjects alongside existing build-time hooks. - Type Definitions: New
PluginModuleinterface documents the full plugin contract (types.ts). - Browser API Client:
docmd-api.jsinjected automatically during dev mode with reconnect and retry logic.
π§° Core Improvements
- Plugin Loader Hardening: Refactored the core module resolver with robust
try/catchfallbacks to gracefully warn against malformed plugins without crashing the build or throwing. - Source Tools: New
getBlockAt,findText,wrapText,insertAfter,replaceBlock,removeBlockutilities for markdown source manipulation. - RPC DOM Mapping: Injected
data-source-fileautomatically into the UI<body>layout container, enabling browser-to-server file tracking during interaction loops. - Bundlephobia Compatibility: Explicitly defined the
"browser": falseboundary on@docmd/coreto prevent legacy external compilers from incorrectly trying to browserify server-side engine APIs. - Codebase Standardization: Comprehensive alignment of license boundaries, boilerplate headers, trailing whitespaces, and metadata schemas across all plugins, legacy setups, and failsafe scripts.
- Git Dev Info: Dev server detects git user info and injects it for plugin author identification (lazy-loaded).
- Path Security: All file operations are sandboxed via
safePath()validation against the project root. - Native File Watcher: Preserved the chokidar-free
fs.watchimplementation introduced in 0.6.6.
π§΅ New Plugin: Threads
- Text selection and highlight-based thread anchoring (
==text=={threadId}syntax). - Full CRUD: create threads, add/edit/delete comments, reply chains, emoji reactions.
- Thread resolution with author tracking and timestamps.
- Author profiles stored in
.threads/authors.jsonwith Gravatar support. - Lit-based Web Components for the client-side UI.
π€ Parser
- Exported
createDepthTrackingContainer: Available viaimport { createDepthTrackingContainer } from '@docmd/parser'for plugin authors building custom container syntax. - Added comprehensive JSDoc documentation to the container API.
π§Ή Bug Fixes & Refactors
- TypeScript Overhauls: Vast strict-null enforcement, non-implicit global declarations, and DOM explicit-typing integrations finalized inside
@docmd/plugin-mermaidand@docmd/plugin-searchclients. - CSS Layout Issues: Fixed iframe aspect-ratios, Hero component bounds, and plugin-threads text area sizing. Realigned responsive padding breakpoints.
- Legacy Header Cleanups: Stripped conflicting or malformed document headers from ecosystem forks and standardized
docmd.iobranding definitions consistently across activepackages/*.
Migration Guide
No breaking changes. The WebSocket RPC protocol is additive β existing live-reload behavior is fully preserved. The new docmd-api.js replaces the inline reload script with an enhanced version that handles both reload and RPC.