WriterAgent

Une extension LibreOffice qui ajoute des fonctionnalités d'IA agentique et NumPy.

Documentation

WriterAgent, LibrePy & LibreHarper

WriterAgent logo

License: GPL v3+ Python 3.11+ LibreOffice 7.0+ Release

CI status CI status page

Python, NumPy, and Agentic AI for LibreOffice (Writer, Calc, and Draw)

Run Python and scientific compute offline in spreadsheet formulas, edit documents with private local-first AI — without cloud lock-in.

The project is distributed as three standalone extension packages (install only one at a time):

PackageWhat's Included
🤖 WriterAgent (WriterAgent.oxt) (Full stack, recommended for most users)Everything in LibrePy and LibreHarper + AI sidebar, =PROMPT(), web research, Calc → Python converter, MCP server
🐍 LibrePy (LibrePy.oxt)Python runtime, =PY(), NumPy, pandas, SymPy, Monaco, Jupyter File → Open .ipynb, domain helpers, OCR (no AI/MCP — core-track build for LO inclusion)
✍️ LibreHarper (LibreHarper.oxt)Standalone offline Harper grammar engine for Writer

Download .oxt Releases · Feature Index · NumPy in LibreOffice Guide · Discussions


Key Capabilities

🤖 Local-First Agentic AI & Writing (Writer)

  • Sidebar Chat with Multi-turn Tool Calling — Edit, restructure, or expand documents using natural language. 9 core tools plus dozens of specialized sub-agents for page layout, footnotes, bookmarks, revisions, and forms.
  • Two-Way Voice Interaction (STT & TTS) — Dictate prompts directly to your document agent and listen to responses spoken aloud (local via Kokoro or Piper, or via your LLM endpoint).
  • Format-Preserving Edits — Surgical redlines and section rewrites maintain your existing formatting (bold, italics, highlights, font sizes, tables, and nested lists) without clobbering styles.
  • Web Research — Integrated private smolagents loop with DuckDuckGo. Synthesizes multiple web sources and updates open documents with real-time facts and citations. Agent Search
  • Real-Time Grammar & Proofreading — Local, privacy-preserving grammar checking via Harper (fast, auto-installing), LanguageTool, or LLM endpoints with mixed-language sentence detection. Details
  • Math & LaTeX Import — Converts LaTeX and MathML into native, editable LibreOffice Math objects. Math Guide

🐍 Python & Scientific Computing (Calc & Writer)

  • Native =PY() Spreadsheet Formulas — Execute Python, NumPy, and pandas expressions directly inside Calc cells with automatic array spill, shared workbook kernels, and persistent scripts.
  • Embedded Monaco Code Editor — Write, test, and debug multi-line Python scripts directly inside cells or through the Tools → Run Python Script environment with syntax highlighting, autocomplete, and diagnostics.
  • Built-in Scientific & Analytics Domains — Ready-to-use helpers for EDA, outlier detection, OLS regression, KMeans clustering, Monte Carlo simulations, symbolic algebra (SymPy), plotting, and physical unit conversions (convert_quantity(60, "mph", "m/s") → 26.8224 m/s). Domain Reference · Analysis Helpers
  • Spreadsheet → Python Converter (WriterAgent) — Translate 235+ classic Calc/Excel formulas into clean Python expressions using the built-in calc.* parity library while preserving constants, dates, and cell formats. Details
  • Local Vision & OCR — Extract text from embedded images or scanned documents directly into Writer and Calc via offline Docling OCR. Vision Guide
  • Jupyter logo Jupyter Notebook Support — File → Open… a .ipynb (or double-click / soffice notebook.ipynb) creates a Writer document with markdown, editable code fields, and ▶ run buttons against a shared Python kernel. Jupyter in Writer
  • Crash-safe by design — NumPy runs out-of-process in your own venv, so a scripting bug can't crash LibreOffice.

📊 Diagrams, Slides & Multi-Modal (Draw & Impress)

  • Diagram & Presentation Generation — Generate, adjust, and style flowcharts, shapes, connectors, speaker notes, and slide transitions through chat commands or Python scripts. Details
  • Image Creation & Editing — Generate a new image from a prompt, or edit a selected graphic in place, on the same endpoint as chat. Inserts into Writer, Calc, Draw, and Impress. Image Generation
  • LO-DOM Semantic Tree — Structural understanding of headings, sections, tables, and relationships across entire documents. Semantic Tree
  • Cross-Document Search & Memory — Query other documents in the same folder via local embeddings / hybrid search, with persistent cross-session agent memory. Embeddings · Memory

🔌 Integrations & Extensibility

Full catalog of capabilities: docs/features.md.


Installation & Setup

  1. Download your chosen .oxt package from Latest Releases and double-click to install (or open LibreOffice and go to Tools → Extension Manager → Add). Remember to install only one extension package.
  2. Restart LibreOffice.
  3. Quick Configuration:
    • Python / LibrePy users: Open Calc, check Tools → LibrePy (or WriterAgent) → Settings → Python, and click Test to verify your environment and NumPy/pandas availability.
    • AI / WriterAgent users: Open WriterAgent → Settings and enter your endpoint (e.g. http://localhost:11434 for local Ollama (no key needed), or an OpenRouter / Together.AI API key). Open the sidebar via View → Sidebar → WriterAgent or press Ctrl+Q / Ctrl+E.

UI Modes: In classic toolbar mode, access tools through the top menubar. In tabbed/ribbon interfaces, use the WriterAgent chat sidebar and/or the Python sidebar (Writer + Calc): Settings ⚙, Python 🐍, LaTeX math or Edit cell, search 🔍 (WriterAgent chat only), and full menus via ☰.

For detailed setup instructions, see the Install and Troubleshooting Guide.


Showcase

Python in LibreOffice Writer

Python in LibreOffice

Spreadsheet Analytics & Dashboard

Chat Sidebar with Dashboard

Hermes + Opus 4.6 (Web Research)

Hermes-Agent / Opus-4.6 Akihabara

Math Expressions & LaTeX

Math Expressions

Arch Linux Resume

Opus 4.6 Resume

Diagrams in Draw

Sonnet 4.6 Visual


Benchmarks & Evaluation

WriterAgent's Eval-1 LLM Evaluation Suite runs models on real Writer, Calc, and Draw jobs through the same tools the sidebar uses, then scores the exported document. Typical tasks: reformatting documents, recalculating taxes, drawing diagrams like the American flag using shapes. Every run is ranked by Value (correctness² ÷ dollars). The table below is the 2026-09-28 complete 29×19 dual-lane board (flag-18 + org_chart_gen, with hand-scored org-chart gallery overrides — 5 visual hard PASS). Full methodology: docs/eval/benchmarks.md.

Cost–quality Pareto fronts

Distance-to-frontier view: docs/eval/pareto-distance.svg.

ModelCorrectness
avg task score (0–1)
Value
Correctness² ÷ $/task
openai/gpt-oss-120b0.921803
openai/gpt-oss-20b0.759524
poolside/laguna-xs-2.10.838358
upstage/solar-pro40.716352
google/gemma-4-31b-it0.861330
google/gemma-4-26b-a4b-it0.701216
bytedance-seed/seed-2.0-mini0.861179
poolside/laguna-s-2.10.732160
meta/muse-spark-1.3-contributor0.981147
openai/gpt-6-luna0.873139
z-ai/glm-5.3-flash0.85687
nvidia/nemotron-3.5-super-vl0.93282
liquid/lfm-2.5-24b-a2b0.58982
prism-ml/ternary-bonsai-2-27b0.54378
deepseek/deepseek-v4.1-flash0.88377
qwen/qwen3.8-flash0.79265
mistralai/mistral-small-26030.58364
meta/muse-glimmer-30b0.92360
inception/mercury-2.5-preview0.81756
ibm-granite/granite-4.2-8b0.81055
google/gemini-3.5-flash-lite0.70849
nvidia/nemotron-3.5-lightning0.39546
nvidia/nemotron-3-super-120b-a12b0.85438
reflection/beam-1.0-501b-a23b0.87918
cohere/command-a-plus0.64113
minimax/minimax-m30.78011
x-ai/grok-4.60.9189
qwen/qwen3.8-27b0.9179
nvidia/nemotron-3-ultra-550b-a55b0.7874

Documentation & Architecture

TopicDocumentation Link
Feature Indexdocs/features.md
NumPy & Python in Calcdocs/enabling_numpy_in_libreoffice.md · docs/calc/py-data-shapes.md
LibrePy Core Architecturedocs/scripting/librepy-split.md
Domain Helper Functionsdocs/scripting/numpy-domains.md · docs/calc/analysis-tools.md
Full Architecturedocs/writeragent-architecture.md · docs/framework/formal-verification.md
Model Context Protocol (MCP)docs/mcp-protocol.md
Embeddings & Searchdocs/embeddings.md
Benchmarksdocs/eval/benchmarks.md
Localization (35 Locales)docs/framework/localization.md
Code ExplorerDeepWiki
Cursor / Agent Skillscursor-libreoffice · libreoffice-skill

Under the hood, all operations are governed by a formally verified finite state machine, with strict type checking and static analysis. Thread-unsafe UNO calls are caught in dev via a viral thread guard proxy, instead of randomly freezing. The mock-LLM sidebar suite — the world's worst LLM — proves Stop, hang, and error recovery end-to-end.

State machine architecture


Project Evolution

A chronicle of building a Python runtime and AI suite inside LibreOffice:


Contributing & Development

Ask DeepWiki Discussions

Prerequisites: Python 3.11–3.13 for development (pinned to 3.13 via .python-version), uv. Run make check-setup to verify. On macOS: install make, gettext.

git clone https://github.com/KeithCu/writeragent.git
cd writeragent
uv python install 3.13
uv sync
make deploy          # Builds & installs WriterAgent.oxt (or: make deploy writer)
make test
make help

To build and test the standalone extension variants:

# Standalone Python / NumPy compute suite (LibrePy)
make build-core      # Produces build/LibrePy.oxt
make deploy-core     # Installs LibrePy.oxt (removes WriterAgent)

# Standalone Harper grammar checker (LibreHarper)
make build-harper    # Produces build/LibreHarper.oxt
make deploy-harper   # Installs LibreHarper.oxt

See AGENTS.md (invariants), docs/repo-map.md (entry points), and docs/scripting/librepy-split.md for architecture details.


Credits

ProjectContribution
localwriterOriginal Writer LLM extension (John Balis)
LibreCalc AI AssistantCalc AI foundation and inspiration
LibreOffice MCP ExtensionMCP server patterns, Makefile, tool registry
Hermes AgentTool-call parsers, JSON repair, memory patterns
latex2mathmlLaTeX → MathML
mathml-to-latexMathML → LaTeX (Writer formula export)
isodateISO 8601 duration parse/format (Calc wire)

License

GNU GPL v3 (or later) — see LICENSE. Originally MPL 2.0; relicensed in 2026 for stronger reciprocity and library compatibility.

YearContributionContributor
2024Original releaseJohn Balis
2025–2026Config, registries, build systemquazardous
2026Calc integration (originally MIT)LibreCalc AI Assistant
2026Modifications and relicensingKeithCu