Thank you for your interest in contributing to InkDoc! We welcome code contributions, bug reports, documentation enhancements, and feature suggestions.
- Pick something small. Issues labeled
good first issueare scoped for newcomers; comment on one to claim it. Questions are welcome on the issue itself. - Set up and run it:
git clone https://github.com/<your-username>/InkDoc.git # your fork cd InkDoc python -m venv .venv # Windows: .venv\Scripts\Activate.ps1 macOS/Linux: source .venv/bin/activate python -m pip install -r requirements.txt python -m pip install ruff==0.16.8 pytest==9.1.1 httpx==0.28.1 httpx2==2.13.0 python main.py # the desktop app; add --headless for the API only
- Check it the way CI does:
ruff check .thenpython -m pytest tests/. - Open a pull request. The template asks what you changed and how you tested it. A focused PR with one change is reviewed fastest.
The rest of this guide is the detail behind those steps.
git clone https://github.com/AbdoslamB/inkdoc.git
cd inkdocCreate a virtual environment and install development dependencies:
python -m venv .venv
# On Windows (PowerShell)
.venv\Scripts\Activate.ps1
# On macOS / Linux
source .venv/bin/activate
# Install dependencies
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install ruff# Run the Desktop Application (Edge WebView2 / WebKit)
python main.py
# Run in Headless API mode
python main.py --headless --port 13118The codebase follows a domain-driven structure:
inkdoc/
├── app/
│ ├── core/ # Conversion business logic & engine adapters
│ │ ├── converter.py # MarkItDown wrapper, option mapping & collision-safe auto-save
│ │ ├── save_location.py # Save folder setting (Downloads by default) & its fallback
│ │ ├── queue_model.py # EngineKind enum, QueueItem data definitions
│ │ └── engines/ # IBM Docling, Markit & GLM-OCR engine adapters
│ ├── server/ # Embedded FastAPI backend
│ │ └── server.py # Local REST endpoints (/convert, /health, /extensions)
│ ├── desktop/ # Native desktop runner
│ │ └── runner.py # pywebview window manager & loopback orchestration
│ └── ui/ # Shared Web & Desktop user interface
│ ├── index.html # DOM layout, dropzone canvas, engine selector pills
│ ├── style.css # Inkbench Obsidian design system (CSS custom properties)
│ └── app.js # Reactive client-side logic & marked.js preview
├── tests/ # Automated integration tests (test_server.py)
├── examples/ # Developer client scripts & demos
├── API.md # REST API reference manual
└── main.py # Unified desktop & headless CLI entry point
Each area of the code has a developer guide in guides/: how it works,
the rules it must keep, the tests that cover it, and lessons from earlier work there.
AGENTS.md says which guide covers which file; read that guide before you change
the file, and update it in the same pull request when the code changes how the area works.
- Backend (Python):
- Write clean, readable Python 3.10+ code with explicit type annotations where appropriate.
- Conversions must never block the main loop; engine operations run asynchronously or in background workers.
- Follow PEP 8 guidelines. Verify your code with
ruff check ..
- Frontend (Web/Desktop UI):
- The UI in
app/ui/is the single source of truth for both the desktop app and the web bench. - Use Vanilla HTML5, CSS Custom Properties, and modern standard JavaScript (ES6+ async/await).
- Adhere to the Inkbench Obsidian design system defined in
app/ui/style.css.
- The UI in
- Cross-Platform Compatibility:
- Keep all features compatible with Windows, macOS, and Linux.
- Use
pathlib.Pathfor filesystem operations rather than platform-specific string concatenation.
A new feature ships inside InkDoc unless at least one of these is true. If one is, it becomes a download (an engine pack or add-on that users install from Settings):
- it needs model weights or a native runtime;
- it adds more than 25 MB to the app or slows its startup;
- it needs separate builds per platform;
- its license isn't a permissive one like MIT, BSD or Apache-2.0 (for example GPL, LGPL, AGPL, MPL, or a model license that restricts use);
- it uses the network.
Not sure? Open an issue first. The full rule is in AGENTS.md.
Steps are what Balanced and Thorough add to an engine's result (for example the table check or chart text). Each one is core code and gets its own switch under Settings → General → Auto quality → Steps automatically. To add one:
- Register it in
app/core/thorough_passes.py: aPassInfowhose place inPASSESis its order, with its lowest level, its stage, the engines it needs (needs_all/needs_any) andmodules, the modules that do its work. - Write the work in its own module under
app/core/, pure where possible. It may import the standard library, InkDoc's own code and the PDF libraries InkDoc ships (pypdfium2, pdfplumber, pdfminer.six); import those libraries inside the function that uses them.tests/test_step_imports.pychecks this. - Call it where its stage runs (
run_autoor_check_tablesinapp/core/auto_engine.py), only whenplan.on("<name>"), and record what it did withlog.ran(...)orlog.skipped(...). That record is the response'stables.passes. - Test it: the step's own behaviour, and its
tables.passesentry (seetests/test_thorough_passes.py).
A step that needs a model is still core code; the model is an add-on. Put the code that runs the model under app/core/engines/ (it runs in the MarkItDown worker, so InkDoc's own process never loads its runtime), describe the model in app/core/addons.json, and name it in the step's needs_all. "Tables on scanned pages" is the example: scanned_tables.py is the step, engines/layout_model.py runs the layout_model add-on.
InkDoc supports optional deep layout parsing via isolated engine packs (IBM Docling). Engine packs are distributed as signed release assets and must satisfy strict cryptographic verification.
- No Placeholders: Never commit placeholder hashes (e.g.
PLACEHOLDER_*), empty hashes, or truncated hashes toapp/core/manifest.json. - Fail Closed: Any missing hash, empty hash, placeholder, or hash that is not a 64-character hex SHA-256 aborts the installation before any archive extraction and marks the engine pack as unsupported for that build.
- Release Guard: CI and Release workflows enforce
python scripts/generate_engine_manifest.py --verify-manifest. Builds fail immediately if the manifest contains placeholder or malformed entries.
- Build the Pack:
python scripts/build_pack.py --output-dir dist/packs
- Compute Real SHA-256 Hashes and File Tree:
python scripts/generate_engine_manifest.py --archive dist/packs/docling-windows-x86_64.zip --platform windows-x86_64
- Update Manifest Directly:
python scripts/generate_engine_manifest.py --archive dist/packs/docling-windows-x86_64.zip --platform windows-x86_64 --update-manifest
- Verify Manifest Integrity:
python scripts/generate_engine_manifest.py --verify-manifest
The layout_model entry in app/core/addons.json ships unreleased, which is valid: with the Docling engine installed, InkDoc uses the identical copy that comes with it, and otherwise the add-on is not offered for download. To publish it:
- Build it:
python scripts/build_layout_addon.py --release-tag layout-addon-v1(add--model-dir <folder>to use a local copy instead of downloading the pinned Hugging Face revision). It refuses anymodel.onnxbut the onepack_copypins, and writesdist/addons/inkdoc-addon-layout_model.tar.gzanddist/addons/addons.jsonwith the asset URL derived from the tag. The archive is reproducible. - Publish the archive on that release tag, not marked Latest (the in-app updater uses
/releases/latest). - Commit
dist/addons/addons.jsonasapp/core/addons.json.scripts/verify_addon_catalogue.pychecks it in CI.
Before submitting a pull request, run the complete verification suite locally:
# 1. Syntax check all source directories
python -m compileall -q main.py app tests examples scripts
# 2. Run the manifest release guard
python scripts/generate_engine_manifest.py --verify-manifest
# 3. Run the whole test suite, exactly as CI does
python -m pytest tests/
# 4. UI logic tests (need Node.js; CI runs every tests/*.test.js on Linux)
(for t in tests/*.test.js; do node "$t" || exit 1; done)
# Optional: how engines read tables, before and after the table check
# (synthetic test pages, plus your own PDFs with NAME.tables.json; see the script)
python scripts/table_bench.py --engines markitdown
# 5. Verify code style with ruff
ruff check .- Open an Issue First: For non-trivial changes, new features, or architectural adjustments, open an issue first to discuss the design.
- Keep PRs Focused: Keep pull requests focused on a single feature or bug fix.
- Describe Your Verification: Document the exact commands you ran and operating systems tested in the PR description using the template.
- Using AI Tools: They're welcome. You are the author of everything you submit: say which parts an AI tool wrote, and review and test all of it. The details are in the AI Policy.
All dependency updates (whether submitted manually or generated automatically by Dependabot) must satisfy the following requirements before merging:
- Automated CI Validation: The PR must cleanly pass all checks in
.github/workflows/ci.ymlacross all supported platforms (Windows, macOS, and Linux). - Smoke Test of Built App: Changes to core desktop runtime dependencies (including
pywebview,fastapi, anduvicorn) require a local smoke test of a built application package to verify that desktop window events, pywebview loopback orchestration, and PyInstaller bundling continue to function without regressions.
Any pull request that adds or upgrades a dependency, a model, or a bundled or downloaded binary must, in the same pull request:
- Check the license at the source. Read the component's own LICENSE file, model card or package metadata for the exact version. Don't rely on memory or on another project's summary. Model weights often have a different license from the code that runs them, so check both.
- Update
THIRD_PARTY_NOTICES.md. Add or update its row: what InkDoc uses it for, upstream URL, copyright holder, exact license, and whether InkDoc bundles it, re-hosts it, mirrors it or lets the user's machine fetch it. If the upstream doesn't state something, write UNVERIFIED instead of guessing. - Add the full license text to
LICENSES/. Copy it unchanged, keeping the original copyright lines, and include any NOTICE file (Apache-2.0 requires it). For Python dependency changes, regenerate the affected list (LICENSES/python-packages-desktop.txtorLICENSES/docling-pack-packages.md) the way its header describes. - Flag copyleft, restricted or unclear licenses. If anything is GPL, LGPL or AGPL, restricts commercial use (for example a non-commercial or research-only model license), or has unclear or custom terms, say so in the pull request description so a maintainer can decide. Don't add it quietly.
Dependabot pull requests need the same check before merging.
The page's JavaScript, CSS and fonts (marked, DOMPurify, highlight.js, KaTeX) are bundled, never fetched at runtime, and pinned by SHA-256 in app/ui/vendor/VENDOR.json. Dependabot does not see them. To update one:
- Download the exact version (
npm pack <name>@<version>) into an empty folder and check that the tarball's sha512 matchesnpm view <name>@<version> dist.integrity. Prefer a release that has been out for at least two weeks. - Copy only the files
VENDOR.jsonlists for that library, unchanged. - Update the library's
version,upstream_integrityand file hashes inVENDOR.json, its row inTHIRD_PARTY_NOTICES.md, and its file inLICENSES/(see above). - Run
python -m pytest tests/test_vendor_manifest.py, then the UI tests and a manual look at the preview.
Files in app/ui/vendor/ are never line-ending converted (see .gitattributes), so their hashes match on every OS.
Only the latest release is supported with security fixes:
| Version | Supported |
|---|---|
| Latest | ✅ |
| Older | ❌ |
If you find a security issue (for example, unsafe handling of untrusted input during file conversion, or something that could execute code from a malicious file), please do not open a public issue.
Instead, report it privately via GitHub Security Advisories for this repository. Include:
- A description of the vulnerability and its impact
- Steps to reproduce it, or a proof-of-concept file if relevant
- The affected version/commit
You will receive an initial response within a few days. Once a fix is available, a new release will be published and the advisory disclosed.
Note
This app wraps Microsoft's markitdown package for primary file parsing and IBM docling for layout analysis. If the issue originates upstream in markitdown or docling itself rather than in InkDoc's code, please also report it upstream following their security policies.
Everyone taking part in InkDoc is expected to follow the Code of Conduct.
Maintainers follow a strict release candidate rehearsal procedure before publishing a stable release:
- Prepare Branch: Verify
CHANGELOG.mdis updated and CI is green onmain. Always tag only from an up-to-datemainbranch:git checkout main git pull origin main
- Push RC Tag:
git tag v1.0.2-rc1 git push origin v1.0.2-rc1
- Automated Pipeline:
create-draft-releaseinitializes a draft release marked as pre-release (--prerelease).buildmatrix builds all platforms, runs full end-to-end smoke testing (--selftest, multi-format document conversions) against built artifacts, and uploads them to the draft.publish-releasepublishes a release-candidate tag automatically as a pre-release. A stable tag is left as a draft so the update manifest can be signed offline and attached before it becomes Latest; publish it by hand with Set as the latest release checked. Seedocs/RELEASE_RUNBOOK.md.
- Validation: Test the uploaded artifacts on real hardware.
If a build step or smoke test fails during a release run, the pipeline aborts without publishing:
- Delete the Draft Release and Remote Tag:
Use
gh release deletewith--cleanup-tagto delete both the GitHub draft release and the remote git tag:gh release delete v1.0.2-rc1 --yes --cleanup-tag
- Delete the Local Git Tag:
git tag -d v1.0.2-rc1
- Fix and Retry as Next RC: Fix the issue on a feature/fix branch, merge to
main, and push the next release candidate tag (v1.0.2-rc2). Never re-use or force-push an existing tag.
Once an RC is fully verified, tag only from an up-to-date main:
git checkout main
git pull origin main
git tag v1.0.2
git push origin v1.0.2A stable tag (no hyphen) stops at a draft: the update manifest is signed offline and attached first, and only then is the release published as Latest. See docs/RELEASE_RUNBOOK.md.