The @docmd/plugin-threads plugin enables collaborative inline commenting and text annotation across documentation pages. Highlights and discussion threads are stored natively inside Markdown source files using custom container blocks (::: threads). No external database is required.

Original Author: @svallory

Alpha Release

This plugin is currently in Alpha. Core APIs and storage schemas are stable, whilst UI components are undergoing active iteration.

Installation & Setup

Install the plugin via CLI:

npx @docmd/core add threads

Enable thread configuration in docmd.config.json:

Option Type Default Technical Description
sidebar boolean false When true, threads display in a dedicated panel; when false, threads attach inline to text highlights.
devOnly boolean true Restricts client UI assets to live dev server builds (docmd dev). Omitted in static production builds (docmd build).

Live Development Server Requirement

The Threads commenting interface, highlighting tools, and Markdown persistence actions require an active live development server (docmd dev) with an active WebSocket RPC connection.

Because Threads declares requiresLiveServer: true:

  • Development (docmd dev): The slide-out handle, inline preview cards, selection popovers, and thread sidebar are fully loaded and operational.
  • Static Production Builds (docmd build): Client scripts and CSS are automatically omitted to ensure that public production sites remain ultra-fast, zero-overhead, and free of broken WebSocket attempts or inactive UI widgets. Any existing Markdown threads syntax (::: threads and ==text=={t-...}) continues to parse cleanly without warnings.
  • Manual Override: If you explicitly wish to bundle Threads client assets into static builds, configure "devOnly": false in plugins.threads.

Global Configuration Example

docmd.config.json
{
  "plugins": {
    "threads": {
      "sidebar": true,
      "devOnly": true
    }
  }
}

Workflow Overview

  1. Text Selection: Select prose during local live development (npx @docmd/core dev).
  2. Comment Popover: Enter feedback in the popover modal.
  3. Anchor Injection: Selected prose is highlighted with a thread identifier (==highlighted text=={t-a1b2c3d4}).
  4. Markdown Persist: Thread structures append to the bottom of the Markdown file as a ::: threads block.
  5. Git Synchronisation: Discussion history is saved in source control alongside document edits.

Interactive Preview

Text with attached discussions receives inline colour highlights. Thread cards render below:

A
Alice · 2d ago
This section could use a diagram to explain the architecture. What do you think?
B
Bob · 1d ago
Good idea - I'll add a Mermaid flowchart. Does sequenceDiagram work here?
👍 2
🚀 1
A
Alice · 12h ago
Perfect. A simple flowchart would be ideal.

Additional highlights cycle through distinct colour palettes automatically:

C
Charlie · 3d ago
Should we mention backward compatibility here?

Resolved discussions display in a dimmed state:

A
Alice · 5d ago  ✓ Resolved
Fixed the typo in the config example.

A right-docked tab trigger 💬2 hugs the right edge of the viewport, displaying unresolved thread counts. Hovering over any highlighted text reveals an inline comment preview card directly within the content, while clicking the tab opens the discussion drawer. Threads persist seamlessly across drawer open and close states without reloading the page.

Markdown Storage Format

Threads are saved inside document source files using container block syntax:

# Engine Overview

Core architecture features ==highlighted text=={t-a1b2c3d4} with an attached thread.

::: threads
  ::: thread t-a1b2c3d4
    ::: comment c-e5f6a7b8 "Alice" "2026-04-09"
      This text requires additional technical detail.
    :::
    ::: comment c-d9e0f1a2 "Bob" "2026-04-09" reply-to c-e5f6a7b8
      Updated with extra specifications.

      ::: reactions
        - 👍 Alice
      :::
    :::
  :::
:::

Core Features

  • Text Selection: Highlight arbitrary prose to anchor new threads.
  • Threaded Replies: Nested conversation threads.
  • Emoji Reactions: Add reaction counters to comments.
  • Resolution State: Mark threads as resolved with author attribution.
  • Author Identity: Local Git credentials resolve avatar and profile details automatically.

RPC Actions API

The Threads plugin exposes WebSocket RPC endpoints accessible via docmd.call():

RPC Method Technical Description
threads:get-threads Retrieve all parsed threads for a given file path.
threads:add-thread Anchor a new thread and initial comment.
threads:add-comment Append a reply to an existing thread.
threads:edit-comment Update comment text body.
threads:delete-comment Remove a comment entry.
threads:delete-thread Remove thread container and clean up body highlight anchors.
threads:resolve-thread Toggle thread resolution state.
threads:toggle-reaction Add or remove emoji reactions.

Author Profile Storage

Author profiles are cached in <docsRoot>/.threads/authors.json:

.threads/authors.json
{
  "alice@example.com": {
    "name": "Alice",
    "avatarUrl": "https://gravatar.com/avatar/..."
  }
}
Git-Native Versioning

Because thread metadata resides entirely inside .md files, comments follow standard Git branching, pull request reviews, and commit history workflows.