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 response
  • docmd.send(name, data) β€” Fire-and-forget events
  • docmd.on(name, callback) β€” Subscribe to server-pushed events
  • docmd.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 reload string 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 actions and events objects alongside existing build-time hooks.
  • Type Definitions: New PluginModule interface documents the full plugin contract (types.ts).
  • Browser API Client: docmd-api.js injected automatically during dev mode with reconnect and retry logic.

🧰 Core Improvements

  • Plugin Loader Hardening: Refactored the core module resolver with robust try/catch fallbacks to gracefully warn against malformed plugins without crashing the build or throwing.
  • Source Tools: New getBlockAt, findText, wrapText, insertAfter, replaceBlock, removeBlock utilities for markdown source manipulation.
  • RPC DOM Mapping: Injected data-source-file automatically into the UI <body> layout container, enabling browser-to-server file tracking during interaction loops.
  • Bundlephobia Compatibility: Explicitly defined the "browser": false boundary on @docmd/core to 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.watch implementation 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.json with Gravatar support.
  • Lit-based Web Components for the client-side UI.

πŸ“€ Parser

  • Exported createDepthTrackingContainer: Available via import { 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-mermaid and @docmd/plugin-search clients.
  • 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.io branding definitions consistently across active packages/*.

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.