Pilcrow
Pilcrow makes Word text changes reviewable in GitHub Desktop. Keep editing the
.docx; export readable companion files and commit both through your normal Git
workflow. The DOCX is authoritative. The prose is a generated review artifact,
not an editable replacement or a round-trip format.
This is an independent, small Python implementation, conceptually inspired by the companion-file approach of stet. No source or tests were copied from that project.
Install
With Node.js 22 or newer:
npx otekin pilcrow
pilcrow --help
The installer installs pilcrow-docx from PyPI for your user account, using uv
and downloading uv and Python if needed. It supports Linux, macOS, and Windows.
If it prints a directory to add to PATH, add that directory and reopen your
terminal. Run npx otekin pilcrow --upgrade to update Pilcrow.
If you already use uv, you can also install directly:
uv tool install pilcrow-docx
Install from source
Requires Python 3.10 or later. Git is needed for repository discovery and the Git workflow. Word is not required to export. From this project's directory:
python -m pip install .
pilcrow --help
Use python3 instead of python on systems where needed. A virtual environment
is recommended (python -m venv .venv); activate it before installing:
- macOS/Linux:
source .venv/bin/activate - Windows PowerShell:
.venv\Scripts\Activate.ps1 - Windows Command Prompt:
.venv\Scripts\activate.bat
If activation is unavailable, invoke .venv/bin/python or
.venv\Scripts\python.exe directly with -m pip install ., then -m pilcrow.
For development, see Development.
Pilcrow uses Python's ZIP reader and defusedxml for XML parsing. There is no Word
process, cloud service, AI connection, watcher, or background service. Extraction
never writes to the DOCX.
Baseline, then review a change
In your document repository, choose an explicit scope. For example:
pilcrow export --all --root .
pilcrow check --all --root .
Or select documents (paths are relative to your current directory):
pilcrow export "report.docx" "chapters/Methods and results.docx" --root .
Outputs retain the complete source-relative filename:
report.docx
chapters/Methods and results.docx
.pilcrow/report.docx.prose.md
.pilcrow/report.docx.meta.json
.pilcrow/chapters/Methods and results.docx.prose.md
.pilcrow/chapters/Methods and results.docx.meta.json
- Export a baseline. In GitHub Desktop, review and commit the DOCX and its two
companion files together. Do not put
.pilcrow/in.gitignore. - Edit and save the DOCX in Word, or use a separate document-editing tool.
- Run the same
pilcrow exportcommand again. - In Desktop's Changes view, select the
.prose.mdfile to read the text diff; inspect.meta.jsonfor review/coverage changes. The DOCX may still say binary changed. Review formatting/images in Word when relevant. - Commit the DOCX and both companions together through Desktop, then push and branch normally. Desktop's History view can show committed companion diffs.
Pilcrow never stages, commits, pushes, switches branches, or merges. No direct DOCX text converter is installed. The CLI and an ordinary Git diff have been tested; the Microsoft Word / GitHub Desktop GUI workflow has not been tested in this Linux environment. See manual validation. See an actual generated prose and Git diff example. Old commits without companions will not gain prose diffs automatically; there is no backfill or history rewriting.
Scope and discovery
--rootdefaults to the current directory, never an automatically detected repository top. It controls both discovery and the location of.pilcrow/. Use the same root each time. From a subdirectory, pass--root ..deliberately if the output belongs at the parent. Explicit paths remain relative to the current directory, not to--root.- Supply paths or
--all. No arguments does not silently scan the machine. Passing a directory as a document is an error; use--all --root directory. - Inside Git,
--allusesgit ls-filesfor tracked and nonignored untracked files within the selected root. Tracked files remain included even if an ignore rule matches. An explicitly selected ignored DOCX is allowed. - Outside Git,
--allrecursively walks the selected directory. Git ignore rules only apply inside a Git worktree; there is no separate ignore syntax. - Both modes exclude Word lock files (
~$…),.pilcrow,.git,.venv,venv,env,node_modules,__pycache__,.tox,.nox,build, anddist. Extension matching is case-insensitive. Unicode and spaces are supported. - Symlink files/paths are rejected; directory walking does not follow symlink directories. Submodule documents are not recursively discovered from the parent repository: select a root inside the submodule.
--allreports orphan companions after source deletion/rename. Remove the old companion files manually if the deletion was intentional and commit those deletions together. Export never automatically deletes review history files. Explicit-file mode checks only selected inputs, not unrelated orphans.
Check before committing
pilcrow check --all --root .
check is read-only, even when files are missing. It recomputes expected prose and
metadata and compares bytes, tolerating ZIP order/compression, run boundaries,
save timestamps, and other ignored Word metadata. It does not use a DOCX-byte hash.
| Exit | Meaning |
|---|---|
| 0 | Successful export, or companions match the supported normalized view |
| 1 | Missing/stale companions in check, or orphan companions in either command |
| 2 | Invalid selection, unreadable/malformed input, unsafe path, or write failure |
Errors identify the file; remaining selected documents are processed after a per-document error. Retry after Word has finished saving if a file is temporarily unreadable or changes during extraction. A fresh result means no supported prose/review changes detected, never that the complete document is identical. Warnings appear on stderr and in metadata even for fresh results. Known coverage limitations do not themselves cause a nonzero exit.
Writes use a temporary file and atomic replacement in the destination directory.
Byte-identical outputs keep their existing modification times. Each file is
atomic, not the whole pair or batch: if interrupted between files, run check
and export again. Avoid concurrent exports into the same root.
Enforce freshness
Pilcrow ships a pre-commit hook and a GitHub Action, so a
document repository can refuse stale companions locally and in CI. Both only run
pilcrow check --all: they never export, stage, or rewrite files. When either
fails, run pilcrow export yourself and commit the DOCX and its companions
together.
Pin both to a Pilcrow release tag (see the repository's Releases). The hook and
action first ship in the release after v0.1.2; the snippets below assume v0.1.3.
.pre-commit-config.yaml in your document repository root (then run
pre-commit install once):
repos:
- repo: https://github.com/omertekin2002/Pilcrow
rev: v0.1.3
hooks:
- id: pilcrow-check
The hook runs pilcrow check --all --root . from the repository root when a commit
adds or changes a DOCX or a file under .pilcrow/. pre-commit does not pass
deleted paths to hooks, so a commit that only deletes files (for example a DOCX
without its companions) skips the hook; the CI check below catches the resulting
orphans. To run the check on every commit instead, add always_run: true under
- id: pilcrow-check. The hook is for the pre-commit framework, run by
git commit once pre-commit install has set it up. It has not been tested with
GitHub Desktop.
.github/workflows/pilcrow.yml in your document repository:
name: Pilcrow
on: [push, pull_request]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: omertekin2002/Pilcrow@v0.1.3
with:
root: . # optional, default "."
python-version: "3.12" # optional, default "3.12"
The action installs Pilcrow from the tagged source into a private virtual environment and fails with Pilcrow's exit code: 1 for missing, stale or orphan companions, 2 for errors.
Branches and conflicts
Opt in to conservative merge rules once, from your document repository root:
pilcrow setup --root .
This appends a managed block to .gitattributes, preserving other rules. Repeating
it is harmless. Review and commit the file through Desktop. Rules mark DOCX and
all .pilcrow/ files -merge (Git's binary merge driver), and companion files as
text eol=lf. Both-sided modifications conflict instead of automatically merging
prose into a document that never existed. Normal one-sided changes still merge.
More-specific nested attributes can override these rules; inspect with
git check-attr merge -- "report.docx" ".pilcrow/report.docx.prose.md" if needed.
When branches conflict:
- Preserve copies of both versions of the DOCX outside the conflicted path.
- Choose the authoritative version or reconcile the documents manually in Word. If using Git commands to select a side, make sure you understand that side in the current merge/rebase. Pilcrow does not make this choice.
- Put the resolved DOCX at its repository path. Regenerate its companions, even if Git did not flag them as conflicted. Never independently accept a merged prose artifact as the Word document.
- Run
pilcrow check --all --root .. Inspect the resulting text and Word file, then mark resolutions and commit using your normal Git workflow.
Git commit identity attributes a snapshot, not every contributor between saves. For basic snapshot attribution:
git blame -- ".pilcrow/report.docx.prose.md"
Word tracked-change authors (included in review metadata) are separate from Git authors. Neither proves an edit came from an AI. Companion metadata can contain comment authors and deleted text: review it before sharing, just as you would the DOCX. No automatic OOXML merging or sentence-lineage system is provided.
Coverage and maintenance
See coverage, normalization, and backlog. The prose retains
common headings, list indentation, tables, notes, headers, and footers. Tracked
insertions/move destinations are included and deletions/move sources omitted.
List bullet/number formats are recorded in metadata, so changing them makes
companions stale; the counters themselves are not shown in prose, and numbered
headings are not compared.
Complex tracked structure/layout is limited and reported. Text box text is shown
between [Text box] and [/Text box] markers after its anchoring paragraph; the
box's position, wrapping, and shape formatting are not compared. Images, charts,
equations, and embedded objects are not rendered; images are recorded in
metadata by content hash, so swapping, adding, removing, or reordering one makes
companions stale (size, position, cropping, and alt text are not compared). Formatting-only edits can
leave both companions unchanged and still matter in Word.
Upgrading from a version that left text box text out: documents with text boxes
report stale companions once, because their prose now includes that text. Run
pilcrow export and commit the refreshed companions.
Upgrading from a version that did not record list formats: every document reports
stale companions once, because .meta.json now always has lists and
list_runs keys (empty for documents without lists). Run pilcrow export and
commit the refreshed companions. A document whose numbering relationship points to
a missing part is now an error, like a missing styles part.
Upgrading from a version that did not record image hashes: every document reports
stale companions once, because .meta.json now always has an images key
(empty for documents without images). This ships with the list-format change
above, so one pilcrow export and commit covers both.
Run the generated-fixture suite:
python -m unittest discover -s tests -v
The implementation has four small modules: prose.py (segmentation), extract.py
(OOXML coverage), files.py (scope and writes), and cli.py (commands). Tests
include temporary Git repositories and failure cases. Generated fixtures do not
establish complete Microsoft Word compatibility. No real/private document corpus
was available for this implementation.
Development
Install Pilcrow in editable mode with the pinned lint and type-check tools, then
run both checks from the project root (they read their settings from
pyproject.toml):
python -m pip install -e '.[dev]'
ruff check .
mypy
ruff check . lints src/, tests/ and scripts/; mypy type-checks
src/pilcrow in strict mode.
Releases
Every pull request runs .github/workflows/ci.yml: the test suite on Linux, macOS
and Windows with Python 3.10 and 3.14 (plus 3.11–3.13 on Linux), a lint job that
runs ruff check . and strict mypy, and a packaging check that builds the sdist
and wheel, runs twine check, and runs the installed wheel. An enforce job
builds a fixture document repository with scripts/make_fixture_repo.py and checks
that the action (uses: ./) and the pre-commit hook (pre-commit try-repo) pass
with fresh companions and fail after the DOCX changes without re-export. The release workflow
below still runs the suite again before publishing.
Every push to main runs .github/workflows/publish.yml. Release runs are queued
and each checks out the current main, including previous release version bumps.
The workflow increments the patch version in pyproject.toml and
src/pilcrow/__init__.py, builds and validates the distributions, runs the test
suite, and verifies the installed CLI version. It then commits the version bump, pushes
the commit and tag atomically, and creates a GitHub release with the wheel and
source archive. Release commits use chore(release): ... [skip ci] to avoid loops.
If main advances during a build, the push fails safely before publishing; the
queued run checks out the newer main.
A separate job uploads those same release files to PyPI using Trusted Publishing.
Configure the PyPI publisher for owner omertekin2002, repository Pilcrow,
workflow publish.yml, and GitHub environment pypi. No PyPI API token is needed.
If only the PyPI upload fails, fix its configuration and use Re-run failed jobs
on that workflow run to retry the existing release without bumping the version.
Metadata
Release files for pilcrow-docx 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pilcrow_docx-0.1.4.tar.gz | 57.5 kB | With provenance | Details for pilcrow_docx-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pilcrow_docx-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for pilcrow_docx-0.1.4-py3-none-any.whl |
Total release size: 81.1 kB
Release files / pilcrow_docx-0.1.4.tar.gz
| Download URL | pilcrow_docx-0.1.4.tar.gz |
|---|---|
| Size | 57.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5ad1c29690249b2bd47de326431c8e4177db54584754b2fa8e970ffdb80c69c3
|
|
BLAKE2b-256 checksum How to use checksums |
444e6a24bd9ebfe7a9c146e243833382bc2109977357899d0ad0c15419767fd5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logRelease files / pilcrow_docx-0.1.4-py3-none-any.whl
| Download URL | pilcrow_docx-0.1.4-py3-none-any.whl |
|---|---|
| Size | 23.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
90e4e10d05bdbf2a052048d002e333a2006938701ef3a8b03572f2aece1dc8c1
|
|
BLAKE2b-256 checksum How to use checksums |
5cbf0965c79b135656985e8f5c352a68dd78020d5b4e231a3475229de234cb71
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logSecurity for pilcrow-docx 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pilcrow_docx-0.1.4.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.