Chefski/docmost-cli

This is a CLI for docmost, designed to be used primarily by Claude Code.

★ 0Forks 0PythonGitHub ↗Compare

README

docmost-cli

PyPI version Python License: AGPL-3.0

A command-line tool for managing Docmost wiki instances from the terminal.


Features

  • Page CRUD -- create, read, update, and delete wiki pages with Markdown content
  • Space management -- list, create, and update workspaces
  • Comments -- add, edit, and list comments on any page
  • Full-text search -- search across pages and attachments
  • Attachment management -- upload, insert, replace, inspect, and download page assets with stable IDs/URLs
  • Portable transfers -- export/import ZIP archives without losing page attachments
  • ProseMirror conversion -- automatic conversion between Docmost's ProseMirror JSON and Markdown
  • Tree view -- display page hierarchies as indented trees
  • Configuration profiles -- manage multiple Docmost instances with named profiles
  • Edition-agnostic -- works with both Docmost Enterprise (API key) and Community (email/password)
  • Unix-friendly output -- data to stdout, messages to stderr; every command is pipeable

Installation

From PyPI (recommended)

pip install docmost-cli

With pipx (isolated environment)

pipx install docmost-cli

From source

git clone https://github.com/glinhard/docmost-cli.git
cd docmost-cli
uv pip install -e .

Quick Start

# 1. Set up your configuration (interactive wizard)
docmost-cli config init

# 2. Test connectivity and authentication
docmost-cli config test

# 3. List all spaces
docmost-cli space list

# 4. Get a page as Markdown
docmost-cli page get <page-id>

# 5. Create a new page from a Markdown file
docmost-cli page create <space-slug> --title "My Page" --file content.md

Command Reference

Command Description
docmost-cli config init Interactive configuration setup wizard
docmost-cli config show Show current configuration (secrets masked)
docmost-cli config set <key> <value> Set a configuration value
docmost-cli config test Test connectivity and authentication
docmost-cli page list <space-slug> List pages in a space (--tree, --json)
docmost-cli page get <page-id> Get page content as Markdown (--meta, --raw)
docmost-cli page create <space-slug> Create a new page (--title, --file, --stdin)
docmost-cli page update <page-id> Update a page (--title, --content, --file)
docmost-cli page delete <page-id> Delete a page (with confirmation, --yes to skip)
docmost-cli page move <page-id> Move a page (--parent, --root, --space, --position)
docmost-cli page duplicate <page-id> Duplicate a page
docmost-cli page copy <page-id> Copy a page to another space (--space)
docmost-cli page children <page-id> List child pages (--json)
docmost-cli page history <page-id> Show page version history (--json)
docmost-cli page export <page-id> Export page (--include-attachments creates a portable ZIP)
docmost-cli page import <space-slug> Import Markdown/HTML or a portable ZIP
docmost-cli space list List all spaces (--detail, --json)
docmost-cli space get <space-slug> Get space details
docmost-cli space create Create a new space (--name, --slug)
docmost-cli space update <space-slug> Update a space (--name, --description)
docmost-cli comment list <page-id> List comments on a page (--json)
docmost-cli comment create <page-id> Add a comment (--content)
docmost-cli comment update <comment-id> Edit a comment (--content)
docmost-cli search query <query> Full-text page search (--space, --limit, --offset, --json)
docmost-cli attachment search <query> Search attachments (--space)
docmost-cli attachment upload <page-id> Upload and insert a file/image (--file, --replace, --json)
docmost-cli attachment info <attachment-id> Show metadata and stable authenticated URL
docmost-cli attachment download <attachment-id> Download an attachment (--output)
docmost-cli workspace info Show workspace details
docmost-cli workspace members List workspace members (--json)
docmost-cli user me Show authenticated user info

Attachments and portable transfers

Upload an image or file directly into a page. The default stdout value is the stable attachment ID; use --json when automation needs both the ID and authenticated URL:

docmost-cli attachment upload <page-id> --file ./diagram.png --json

Replace attachment bytes without changing links (Docmost requires the same file extension):

docmost-cli attachment upload <page-id> --file ./diagram-v2.png \
  --replace <attachment-id> --json

Portable page archives use Docmost's native ZIP format and retain their asset files:

docmost-cli page export <page-id> --include-attachments --output page.zip
docmost-cli page import engineering --file page.zip

sync pull downloads referenced assets beneath files/<attachment-id>/<filename> and records their hashes and owning pages in .docmost-manifest.json. sync push uploads new local assets and replaces changed assets in place, while writing the stable attachment ID back into Docmost page content. Relative image/file links to existing local files are treated as page assets.

Pulls are staged and validated before the live directory is replaced. If any page or attachment fails to download, the previous sync remains unchanged. A forced pull removes stale pages and assets recorded by the old manifest, including files renamed remotely, while preserving unrelated local files. The CLI aborts if the target changes while downloads are in progress. Publication uses an atomic directory exchange where the platform supports it and a durable recovery journal for portable fallback.

Every pull also records a canonical fingerprint of each page's raw server state. Before updating, moving, or deleting a page, sync push verifies that fingerprint against /pages/info and aborts the entire push if the page changed remotely. Preserve local edits, pull the space into a separate directory with sync pull <space> --dir <new-directory>, and merge the two copies; do not run a force pull over uncommitted local edits. sync push --force deliberately bypasses a stale baseline; forced conflicting pages keep their previous baseline so a later normal push still requires reconciliation. Manifests created before this protection remain readable, but mutating their pages requires reconciliation or explicit --force.

Tracked attachments retain their pulled byte fingerprint and server update revision. Before replacing locally changed attachment bytes in place, push downloads and verifies the current remote bytes against that fingerprint.

This safeguard is a preflight check, not atomic compare-and-swap. Current Docmost page mutation endpoints do not accept a conditional revision token, so an edit racing after the check can still be overwritten.

Sync uses Docmost's server-side Markdown conversion as the canonical local representation. Every pull pairs that Markdown with the same page revision's exact ProseMirror JSON, stores the raw source under .docmost/raw-pages/, and records editor features that Markdown cannot preserve. Concurrent page changes during pull are retried. If a local content or attachment change would replace a page containing protected features (for example mentions, comments, columns, transclusions, embeds, alignment, colors, or merged cells), sync push stops before making any server changes. Guarded pages are fetched again immediately before replacement so rich content added in Docmost after the last pull is also protected. Title, icon, and parent-only changes remain safe. Manifests from older CLI versions remain usable; run a fresh pull to enable the rich-content guard for those pages. If a successful server response contains no canonical Markdown, pull still produces readable compatibility output but protects that page from content pushes because the compatibility converter is not lossless.

Configuration

Config file location

~/.config/docmost-cli/config.toml

Override with --config /path/to/config.toml on any command.

Profiles

The config file supports multiple named profiles for managing different Docmost instances:

[default]
url = "https://docs.example.com"
api_key = "dm_xxxxxxxxxxxxxxxxxxxx"

[staging]
url = "https://staging-docs.example.com"
api_key = "dm_yyyyyyyyyyyyyyyyyyyy"

Switch profiles with --profile or -p:

docmost-cli --profile staging space list

Environment variables

All configuration values can be overridden via environment variables:

Variable Description
DOCMOST_URL Docmost instance URL
DOCMOST_API_KEY API key (Enterprise edition)
DOCMOST_EMAIL Login email (Community edition)
DOCMOST_PASSWORD Login password (Community edition)
DOCMOST_PROFILE Active profile name

Environment variables take precedence over config file values.

Authentication

Enterprise edition (API key)

Use an API key for authentication. Set it in the config file or via DOCMOST_API_KEY:

docmost-cli config set api_key "dm_xxxxxxxxxxxxxxxxxxxx"

Community edition (email/password)

Use email and password for session-based authentication:

docmost-cli config set email "[email protected]"
docmost-cli config set password "secret"

The CLI automatically detects which auth method to use: if api_key is present it uses token auth, otherwise it falls back to email/password session auth.

Tab Completion

Enable shell tab completion for all commands and options:

docmost-cli --install-completion

Supports bash, zsh, fish, and PowerShell.

Development

# Clone and install in development mode
git clone https://github.com/glinhard/docmost-cli.git
cd docmost-cli
uv pip install -e ".[dev]"

# Run tests
pytest

# Check the pinned CLI contract against a Docmost source checkout
python scripts/check_docmost_contracts.py --docmost-repo ../docmost

# Run tests with coverage
pytest --cov=docmost_cli

# Linting and formatting
ruff check src/ tests/
ruff format src/ tests/

# Type checking
mypy src/

Real-instance tests are disabled by default and require both an explicit command-line opt-in and dedicated test-instance configuration. See Contract and integration testing for the safety gates, Community and Enterprise setup, and cleanup behavior.

Acknowledgments

This CLI is a third-party tool for Docmost, an open-source collaborative wiki and documentation platform — an alternative to Confluence and Notion. Docmost is created by @Philipinho and contributors, licensed under AGPL-3.0.

License

AGPL-3.0. See LICENSE for details.

Contributors

glinhardChefski

Issues