Vai al contenuto principale
V

dsh-asciidoc-preview

vvvollove/dsh-asciidoc-preview

Renders AsciiDoc files in the DeepSeek Harness right Sidebar document preview with a split live editor, click-to-source, and workspace-confined saving.

Installazione

dsh plugin --profile web add github:vvvollove/dsh-asciidoc-preview

README

English | Русский

AsciiDoc preview

Renders AsciiDoc files in the DeepSeek Harness Web GUI. Open an .adoc, .asciidoc, or .ad file in the right Sidebar's document preview and read it as formatted HTML instead of source text. The pencil action in the preview header opens a split editor with a live preview, so the source and its rendering stay side by side.

Install

The repository root is the plugin package. Install it with the DSH CLI:

dsh plugin --profile <profile> add github:vvvollove/dsh-asciidoc-preview

Replace <profile> with the profile your host runs (web, desktop, or a custom profile name). You can also install it from the Plugins page when your host accepts a GitHub or npm source. After installation, enable the plugin row if it is not already active.

Once the package is published to npm, the shorter form will work:

dsh plugin --profile <profile> add dsh-asciidoc-preview

Repository: https://github.com/vvvollove/dsh-asciidoc-preview

What it adds

The plugin registers a document renderer for the three AsciiDoc suffixes with the right Sidebar's document preview. The preview's existing workspace file list and its in-pane navigator choose the file; the preview's file observation reloads the content and this renderer re-converts it when the file changes on disk.

  • Viewer menu: the preview header shows AsciiDoc as the active viewer, with Plain text still offered for the source.
  • Edit mode: the pencil action in the preview header switches the body to a split surface — source on the left, live preview on the right (stacked when the pane is narrow, with Split / Edit / Preview controls and a draggable divider). Save or Ctrl+S writes the file; the eye action returns to the read-only preview.
  • Saving: the Host route checks the Web carrier's trust fence, restricts the path to the session workspace and the three AsciiDoc suffixes, writes atomically with a source-version guard, and applies the session's sandbox policy. A stale save offers Reload or an explicit Overwrite; an external change while the editor is clean reloads it, while unsaved changes show a banner. The editor keeps the file's BOM and uniform line ending (LF or CRLF) on save.
  • Editor surface: Ctrl+S works inside the editor surface only, not globally; the header pencil appears next to the viewer menu, and the split can be resized with the divider or the arrow keys on its focused separator. Files above the 8 MiB save cap are refused before the editor opens.
  • Click-to-source: while editing, a plain click on a rendered block moves the source caret to that block's first line and scrolls it into view. Clicking in Preview mode switches to Split first. Links and cross-references keep their normal behavior; the read-only preview outside Edit does not map clicks.
  • Shadow DOM: the converted document is painted into a shadow root with its own stylesheet, so Asciidoctor markup, tables, and code blocks cannot restyle the Harness UI.
  • Themes: every color comes from --dsw-alias-* theme tokens, so the document follows the app's light and dark themes. The admonition glyphs use the state tokens for note, tip, warning, caution, and important. Typography uses the host's --dsw-font-markdown-*, --dsh-content-font-size, and --dsh-code-font-size tokens, so the document follows the user's font family and size settings.
  • Callouts and icons: code callouts become numbered badges and icon:name[] macros render as glyphs instead of missing images.
  • Offline conversion: rendering happens in the browser with a vendored copy of @asciidoctor/core 4.3.0. The conversion makes no network request and no server-side call; safe: 'secure' disables include:: and other file directives. Remote or absolute images referenced by the document may still be loaded by the browser.
  • Sanitized output: raw HTML passthrough blocks are parsed in an inert document first. Scripts, frames, styles, form controls, event handlers, javascript: URLs, and inline positioning are removed before the fragment enters the shadow tree.
  • Localized copy: English, Russian, and Chinese; other locales fall back to English.

Use it

  1. Install the plugin (see Install) and enable it in Settings → Plugins if it is not already active.
  2. Open the right Sidebar (the panel toggle in the conversation header).
  3. Pick a .adoc, .asciidoc, or .ad file from the workspace file list, or use the preview's navigator toggle to choose another file.
  4. Edit and save the file; the preview re-renders automatically. Use the reload control to force a read, and Plain text in the viewer menu to see the source.
  5. Click the pencil button in the preview header to edit. The split surface reads the whole file, shows a live preview after a short pause, and can be switched between Split, Edit, and Preview.
  6. Save with Ctrl+S or the Save button. The preview inside the split updates immediately; the host preview and any other tab watching the file update through the normal file observation.
  7. Click a rendered block in the split preview to place the caret on its source line. In Preview mode the click switches to Split first.
  8. Click the eye button in the header to return to the read-only preview. If the source has unsaved changes, a confirmation asks before discarding them.

Editing only works inside the session workspace. A read-only session refuses the save and explains why; switch the permission mode to write.

Build

client.js is generated from src/client.template.js and vendor/asciidoctor-browser.esm.js:

node scripts/build-client.mjs
node scripts/smoke-test.mjs
node scripts/host-smoke-test.mjs

Node.js 20 or newer is the only requirement; the scripts use Node built-ins and the vendored Asciidoctor browser build, so there are no dependency installs. Run the smoke tests before the build to check the committed client.js against the template, then build and confirm the bundle is current.

Limitations

  • Editing is workspace-only. The save route refuses a target outside the session's current working directory, follows symlinks through fs.resolve, and accepts only .adoc, .asciidoc, and .ad files. File selection still uses the existing workspace list and preview navigator.
  • Read-only sessions cannot save. The write uses the session's sandbox policy; a read-only session shows the refusal and asks the user to switch the permission mode.
  • Version conflicts are explicit. A save guarded by the version the editor read returns 409 stale if the file changed; the banner offers Reload or an explicit Overwrite. A clean editor reloads automatically when the file changes.
  • The draft is page-local. Closing the preview tab, reloading the page, or switching away from the plugin loses an unsaved draft; there is no server-side draft store.
  • Click-to-source is block-level. Sections map to the heading line, paragraphs to their first line, lists and tables and code blocks to their block start. It does not resolve the exact word or code line, and the read-only preview outside Edit does not map clicks. Links keep their link behavior.
  • Plain textarea. The split editor is a monospace <textarea> without syntax highlighting or line numbers; the read-only renderer remains unchanged.
  • Not a full IDE. There is no search, multi-cursor, or formatting.
  • Workspace-relative images become a labelled placeholder. Images with http(s):, data:, or root-relative URLs render; a workspace-relative path cannot be resolved by this renderer, so a dashed placeholder shows its alt text instead of a broken image.
  • No includes, docinfo, or Asciidoctor extensions. safe: 'secure' refuses includes, and no extension registry is loaded.
  • Paged read-only view, bounded editor. The read-only preview reads text in bounded pages; very large documents show what has been read so far. The split editor reads the complete file and refuses files above 8 MiB up front, matching the Host save cap.
  • A metadata failure can still race. External-change detection rides the preview owner's file observation. A deleted file is reported when the resource fails or the save returns not-found; a transient watch failure may delay that notice, but the version guard still prevents a silent overwrite.
  • No syntax highlighting. Code blocks keep their language class and monospace styling but are not tokenized.
  • No source-line navigation. A file link with a :line parameter opens at the top of the rendered document.

Security

The Host save route and its constraints are described in SECURITY.md. The plugin makes no network requests for rendering and does not read credentials.

License

Plugin code: MIT (see LICENSE). Vendored @asciidoctor/core browser build: MIT, see vendor/asciidoctor-LICENSE.txt.

Plugin correlati