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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47e6e1e1a4647f04f1188167d5303304c28ac8476c17913f2369af5a4a63f970
|
|
| MD5 |
485605b009b37d8ec750815afd967143
|
|
| BLAKE2b-256 |
018c59218d031eb99dde0b3da43cd0f95194f490632c83c39760135fc94b9d62
|
Provenance
The following attestation bundles were made for aioffice-0.1.0.tar.gz:
Publisher:
publish.yml on HuiTurn/aioffice
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aioffice-0.1.0.tar.gz -
Subject digest:
47e6e1e1a4647f04f1188167d5303304c28ac8476c17913f2369af5a4a63f970 - Sigstore transparency entry: 2226334890
- Sigstore integration time:
-
Permalink:
HuiTurn/aioffice@724523442167ed86e0f77573d3ac502c1b138196 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/HuiTurn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@724523442167ed86e0f77573d3ac502c1b138196 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43f0ad0e5110cd04caab9970230b6887d7410ca6426fad3932444d37f9131762
|
|
| MD5 |
1971499e26bee34e9e5066e13aabda00
|
|
| BLAKE2b-256 |
9363ba5609803a6445e26546b8a920689b4511f3b001a86207a691cd820d1ed4
|
Provenance
The following attestation bundles were made for aioffice-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on HuiTurn/aioffice
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aioffice-0.1.0-py3-none-any.whl -
Subject digest:
43f0ad0e5110cd04caab9970230b6887d7410ca6426fad3932444d37f9131762 - Sigstore transparency entry: 2226335490
- Sigstore integration time:
-
Permalink:
HuiTurn/aioffice@724523442167ed86e0f77573d3ac502c1b138196 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/HuiTurn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@724523442167ed86e0f77573d3ac502c1b138196 -
Trigger Event:
push
-
Statement type: