tupik's profile picture
tupik

export-to-docx

Public

Forked from acmar/export-to-word-plugin

It saves from chat to docx file. Markdown/Tables in chat exports too. An empty file may be created from template. You may append new paragraph to existing file. (The `docx` Library is excluded now).

436 Downloads

README

LM Studio Plugin - Export to Word Docx

This plugin allows LM Studio models to export chat conversations into formatting-rich Word (.docx) documents, support structured tables, and append new content to existing files.

The Story & Architecture

Initially, this plugin was designed to use the heavy docx library. However, due to node environment warnings (like --localstorage-file) and rigid file-creation limits, the library was completely removed. (after rev.10) Instead of generating a document from scratch, this plugin uses a lightweight, ultra-stable boilerplate approach: it takes a ready-made document template (empty_template.json, which is a renamed valid .docx file) and performs lightning-fast XML injections directly into the archive using adm-zip.

Key Features

  • Full Chat Export: Exports conversations including Roles (User, Assistant, System), text content, and timestamps.
  • Native Table Formatting: Automatically parses Markdown tables into proper Microsoft Word table grids with clean borders.
  • Incremental Appending: Supports adding new paragraphs and headers to an already existing document without rewriting the whole file.
  • Rich Typography: Full support for standard Markdown formatting (# headers, **bold**, __bold__, etc.).
  • High Compatibility: Generated documents open flawlessly in Microsoft Word, LibreOffice, and Google Docs.

Installation & Deployment

Run the following commands in your plugin directory:

npx tsc
lms dev 
lms dev -install -y

Alternatively, you can fetch the plugin directly via the LM Studio CLI once published:

lms get tupik/export-to-docx -y

Available Tools

  • export_to_docx: Parses the current chat history, builds structural XML elements, and generates a structured document.
  • create_empty_docx: Copies the core empty_template.json boilerplate to create a fresh, valid, and blank .docx file in your workspace.
  • append_paragraph: Opens an existing document, locates the end of the document body, and appends new Markdown text or tables.

Assumed system prompt

You have access to Word generation tools. Strict execution rules:

  • To start an empty document, call create_empty_docx first.
  • From the result of create_empty_docx, extract the path or filename.
  • To add content (text or tables), call append_paragraph. Pass the exact SAME filename/path you obtained in step 2. Do not omit the extension.
  • You can call append_paragraph multiple times sequentially to build a large document.
  • If the function returned Success, do not add this paragraph anymore.
  • Full chat (or it's part) is better output via `export_to_docx.

Inspired by and alternative to: