Skip to main content

An AI-native, declarative document engine for creating and validating office artifacts.

Project description

AiOffice

AiOffice is an AI-native, declarative document engine. It lets an agent describe the document it wants, validates that intent as a strict spec, and compiles it into office formats without exposing low-level Word object APIs.

This first 0.1.0 release is an intentionally small, usable vertical slice of the larger AiOffice architecture:

  • strict AiOffice Document Spec 1.0 draft models;
  • stable semantic node IDs;
  • a Python API and convenience builder;
  • JSON and Markdown input;
  • JSON, Markdown, semantic HTML, and DOCX output;
  • machine-readable validation diagnostics;
  • atomic, revision-checked document patches;
  • a CLI shared with the Python core.

Workbook, presentation, PDF, DOCX import, persistent revision history, rendering, and MCP are planned, but are not claimed by this release.

Install

pip install aioffice

AiOffice requires Python 3.11 or newer.

Python quick start

from aioffice.documents import DocumentBuilder

doc = (
    DocumentBuilder(title="Project Report", theme="business-clean")
    .heading("Project Report", id="report_title")
    .paragraph("The first delivery milestone is complete.", id="status")
    .bullet_list(["Validated spec", "Generated DOCX", "Published HTML preview"])
    .build()
)

validation = doc.validate()
assert validation.valid

doc.export("report.json")
doc.export("report.md")
doc.export("report.html")
doc.export("report.docx")

You can also create a document directly from the strict spec:

from aioffice.documents import Document

doc = Document.from_spec({
    "metadata": {"title": "Project Report"},
    "theme": {"ref": "business-clean"},
    "content": [
        {"type": "heading", "level": 1, "text": "Project Report"},
        {"type": "paragraph", "text": "The first milestone is complete."},
    ],
})

Atomic patch

Patches never mutate the source Document. A successful result contains the next logical revision:

result = doc.apply(
    [
        {
            "op": "text.replace",
            "target": "#status",
            "search": "complete",
            "replacement": "approved",
        }
    ],
    base_revision=doc.revision,
    dry_run=True,
)

assert result.success
preview = result.document

V0.1 supports text.replace, node.append, node.insert_after, node.remove, and node.update. Selectors are stable node IDs in this release.

CLI

aioffice inspect examples/report.json
aioffice validate examples/report.json
aioffice build examples/report.json --output report.docx
aioffice export examples/report.json --to report.html
aioffice schema --output document.schema.json

Patch files may be an operation array or an envelope:

{
  "base_revision": 1,
  "idempotency_key": "agent-task-001",
  "operations": [
    {
      "op": "text.replace",
      "target": "#status",
      "search": "第一阶段",
      "replacement": "第二阶段"
    }
  ]
}

Preview or commit it without overwriting the input:

aioffice apply examples/report.json patch.json --dry-run
aioffice apply examples/report.json patch.json --output updated.json

Development and release

python -m unittest discover -s tests -v
python -m build
python -m twine check dist/*

Production releases use PyPI Trusted Publishing. The tag must match the package version in src/aioffice/_version.py; pushing it starts .github/workflows/publish.yml:

git tag v0.1.0
git push origin v0.1.0

No long-lived PyPI API token is stored in GitHub.

The current spec is a draft. Compatibility will be maintained within the 0.1.x series where practical, but the public model can still evolve before 1.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aioffice-0.1.0.tar.gz (27.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aioffice-0.1.0-py3-none-any.whl (27.4 kB view details)

Uploaded Python 3

File details

Details for the file aioffice-0.1.0.tar.gz.

File metadata

  • Download URL: aioffice-0.1.0.tar.gz
  • Upload date:
  • Size: 27.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for aioffice-0.1.0.tar.gz
Algorithm Hash digest
SHA256 47e6e1e1a4647f04f1188167d5303304c28ac8476c17913f2369af5a4a63f970
MD5 485605b009b37d8ec750815afd967143
BLAKE2b-256 018c59218d031eb99dde0b3da43cd0f95194f490632c83c39760135fc94b9d62

See more details on using hashes here.

Provenance

The following attestation bundles were made for aioffice-0.1.0.tar.gz:

Publisher: publish.yml on HuiTurn/aioffice

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aioffice-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: aioffice-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 27.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for aioffice-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 43f0ad0e5110cd04caab9970230b6887d7410ca6426fad3932444d37f9131762
MD5 1971499e26bee34e9e5066e13aabda00
BLAKE2b-256 9363ba5609803a6445e26546b8a920689b4511f3b001a86207a691cd820d1ed4

See more details on using hashes here.

Provenance

The following attestation bundles were made for aioffice-0.1.0-py3-none-any.whl:

Publisher: publish.yml on HuiTurn/aioffice

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page