docmost-cli 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. docmost_cli-0.4.0/.claude/skills/docmost/SKILL.md +117 -0
  2. docmost_cli-0.4.0/.claude/skills/docmost/examples.md +85 -0
  3. docmost_cli-0.4.0/.gitignore +52 -0
  4. docmost_cli-0.4.0/CHANGELOG.md +102 -0
  5. docmost_cli-0.4.0/CLAUDE.md +117 -0
  6. docmost_cli-0.4.0/LICENSE +661 -0
  7. docmost_cli-0.4.0/PKG-INFO +241 -0
  8. docmost_cli-0.4.0/README.md +201 -0
  9. docmost_cli-0.4.0/SPECIFICATION.md +858 -0
  10. docmost_cli-0.4.0/man/man1/docmost-cli-attachment.1 +57 -0
  11. docmost_cli-0.4.0/man/man1/docmost-cli-comment.1 +92 -0
  12. docmost_cli-0.4.0/man/man1/docmost-cli-config.1 +127 -0
  13. docmost_cli-0.4.0/man/man1/docmost-cli-page.1 +412 -0
  14. docmost_cli-0.4.0/man/man1/docmost-cli-search.1 +90 -0
  15. docmost_cli-0.4.0/man/man1/docmost-cli-space.1 +111 -0
  16. docmost_cli-0.4.0/man/man1/docmost-cli-sync.1 +206 -0
  17. docmost_cli-0.4.0/man/man1/docmost-cli-user.1 +39 -0
  18. docmost_cli-0.4.0/man/man1/docmost-cli-workspace.1 +68 -0
  19. docmost_cli-0.4.0/man/man1/docmost-cli.1 +301 -0
  20. docmost_cli-0.4.0/pyproject.toml +84 -0
  21. docmost_cli-0.4.0/src/docmost_cli/__init__.py +5 -0
  22. docmost_cli-0.4.0/src/docmost_cli/__main__.py +18 -0
  23. docmost_cli-0.4.0/src/docmost_cli/api/__init__.py +5 -0
  24. docmost_cli-0.4.0/src/docmost_cli/api/attachments.py +30 -0
  25. docmost_cli-0.4.0/src/docmost_cli/api/auth.py +202 -0
  26. docmost_cli-0.4.0/src/docmost_cli/api/client.py +296 -0
  27. docmost_cli-0.4.0/src/docmost_cli/api/comments.py +103 -0
  28. docmost_cli-0.4.0/src/docmost_cli/api/pages.py +530 -0
  29. docmost_cli-0.4.0/src/docmost_cli/api/pagination.py +94 -0
  30. docmost_cli-0.4.0/src/docmost_cli/api/search.py +40 -0
  31. docmost_cli-0.4.0/src/docmost_cli/api/spaces.py +141 -0
  32. docmost_cli-0.4.0/src/docmost_cli/api/users.py +25 -0
  33. docmost_cli-0.4.0/src/docmost_cli/api/workspace.py +43 -0
  34. docmost_cli-0.4.0/src/docmost_cli/cli/__init__.py +3 -0
  35. docmost_cli-0.4.0/src/docmost_cli/cli/attachment.py +30 -0
  36. docmost_cli-0.4.0/src/docmost_cli/cli/comment.py +83 -0
  37. docmost_cli-0.4.0/src/docmost_cli/cli/config_cmd.py +143 -0
  38. docmost_cli-0.4.0/src/docmost_cli/cli/main.py +133 -0
  39. docmost_cli-0.4.0/src/docmost_cli/cli/page.py +382 -0
  40. docmost_cli-0.4.0/src/docmost_cli/cli/search.py +33 -0
  41. docmost_cli-0.4.0/src/docmost_cli/cli/space.py +57 -0
  42. docmost_cli-0.4.0/src/docmost_cli/cli/sync_cmd.py +122 -0
  43. docmost_cli-0.4.0/src/docmost_cli/cli/user.py +25 -0
  44. docmost_cli-0.4.0/src/docmost_cli/cli/workspace.py +40 -0
  45. docmost_cli-0.4.0/src/docmost_cli/config/__init__.py +23 -0
  46. docmost_cli-0.4.0/src/docmost_cli/config/settings.py +23 -0
  47. docmost_cli-0.4.0/src/docmost_cli/config/store.py +160 -0
  48. docmost_cli-0.4.0/src/docmost_cli/convert/__init__.py +3 -0
  49. docmost_cli-0.4.0/src/docmost_cli/convert/prosemirror_to_md.py +300 -0
  50. docmost_cli-0.4.0/src/docmost_cli/models/__init__.py +3 -0
  51. docmost_cli-0.4.0/src/docmost_cli/models/common.py +3 -0
  52. docmost_cli-0.4.0/src/docmost_cli/output/__init__.py +17 -0
  53. docmost_cli-0.4.0/src/docmost_cli/output/formatter.py +85 -0
  54. docmost_cli-0.4.0/src/docmost_cli/output/tree.py +66 -0
  55. docmost_cli-0.4.0/src/docmost_cli/py.typed +0 -0
  56. docmost_cli-0.4.0/src/docmost_cli/sync/__init__.py +57 -0
  57. docmost_cli-0.4.0/src/docmost_cli/sync/diff.py +156 -0
  58. docmost_cli-0.4.0/src/docmost_cli/sync/frontmatter.py +152 -0
  59. docmost_cli-0.4.0/src/docmost_cli/sync/manifest.py +195 -0
  60. docmost_cli-0.4.0/src/docmost_cli/sync/pull.py +158 -0
  61. docmost_cli-0.4.0/src/docmost_cli/sync/push.py +374 -0
  62. docmost_cli-0.4.0/tests/__init__.py +0 -0
  63. docmost_cli-0.4.0/tests/conftest.py +49 -0
  64. docmost_cli-0.4.0/tests/fixtures/code_block.json +14 -0
  65. docmost_cli-0.4.0/tests/fixtures/code_block.md +6 -0
  66. docmost_cli-0.4.0/tests/fixtures/empty_doc.json +4 -0
  67. docmost_cli-0.4.0/tests/fixtures/empty_doc.md +1 -0
  68. docmost_cli-0.4.0/tests/fixtures/headings_and_text.json +32 -0
  69. docmost_cli-0.4.0/tests/fixtures/headings_and_text.md +11 -0
  70. docmost_cli-0.4.0/tests/fixtures/lists.json +45 -0
  71. docmost_cli-0.4.0/tests/fixtures/lists.md +5 -0
  72. docmost_cli-0.4.0/tests/fixtures/marks.json +19 -0
  73. docmost_cli-0.4.0/tests/fixtures/marks.md +1 -0
  74. docmost_cli-0.4.0/tests/fixtures/simple_paragraph.json +11 -0
  75. docmost_cli-0.4.0/tests/fixtures/simple_paragraph.md +1 -0
  76. docmost_cli-0.4.0/tests/fixtures/table.json +31 -0
  77. docmost_cli-0.4.0/tests/fixtures/table.md +4 -0
  78. docmost_cli-0.4.0/tests/test_api/__init__.py +0 -0
  79. docmost_cli-0.4.0/tests/test_api/test_attachments.py +45 -0
  80. docmost_cli-0.4.0/tests/test_api/test_auth.py +129 -0
  81. docmost_cli-0.4.0/tests/test_api/test_client.py +139 -0
  82. docmost_cli-0.4.0/tests/test_api/test_comments.py +72 -0
  83. docmost_cli-0.4.0/tests/test_api/test_pages.py +289 -0
  84. docmost_cli-0.4.0/tests/test_api/test_pagination.py +62 -0
  85. docmost_cli-0.4.0/tests/test_api/test_search.py +38 -0
  86. docmost_cli-0.4.0/tests/test_api/test_spaces.py +105 -0
  87. docmost_cli-0.4.0/tests/test_api/test_users.py +26 -0
  88. docmost_cli-0.4.0/tests/test_api/test_workspace.py +60 -0
  89. docmost_cli-0.4.0/tests/test_cli/__init__.py +0 -0
  90. docmost_cli-0.4.0/tests/test_cli/test_attachment_commands.py +63 -0
  91. docmost_cli-0.4.0/tests/test_cli/test_comment_commands.py +91 -0
  92. docmost_cli-0.4.0/tests/test_cli/test_config_commands.py +57 -0
  93. docmost_cli-0.4.0/tests/test_cli/test_page_commands.py +562 -0
  94. docmost_cli-0.4.0/tests/test_cli/test_search_commands.py +41 -0
  95. docmost_cli-0.4.0/tests/test_cli/test_space_commands.py +76 -0
  96. docmost_cli-0.4.0/tests/test_cli/test_sync_commands.py +388 -0
  97. docmost_cli-0.4.0/tests/test_cli/test_user_commands.py +28 -0
  98. docmost_cli-0.4.0/tests/test_cli/test_workspace_commands.py +53 -0
  99. docmost_cli-0.4.0/tests/test_config/__init__.py +0 -0
  100. docmost_cli-0.4.0/tests/test_config/test_settings.py +36 -0
  101. docmost_cli-0.4.0/tests/test_config/test_store.py +128 -0
  102. docmost_cli-0.4.0/tests/test_convert/__init__.py +0 -0
  103. docmost_cli-0.4.0/tests/test_convert/test_prosemirror_to_md.py +194 -0
  104. docmost_cli-0.4.0/tests/test_output/__init__.py +0 -0
  105. docmost_cli-0.4.0/tests/test_output/test_tree.py +65 -0
  106. docmost_cli-0.4.0/tests/test_sync/__init__.py +0 -0
  107. docmost_cli-0.4.0/tests/test_sync/test_diff.py +889 -0
  108. docmost_cli-0.4.0/tests/test_sync/test_frontmatter.py +297 -0
  109. docmost_cli-0.4.0/tests/test_sync/test_manifest.py +279 -0
  110. docmost_cli-0.4.0/tests/test_sync/test_pull.py +348 -0
  111. docmost_cli-0.4.0/tests/test_sync/test_push.py +842 -0
@@ -0,0 +1,117 @@
1
+ ---
2
+ name: docmost
3
+ description: "Read, create, update, and search Docmost wiki pages. Use when the user wants to interact with their Docmost wiki -- reading documentation, creating pages, searching for information, or updating content."
4
+ argument-hint: "[action] [details]"
5
+ allowed-tools: "Bash(docmost-cli *)"
6
+ ---
7
+
8
+ # Docmost Wiki Interaction
9
+
10
+ You have access to `docmost-cli`, a CLI tool for managing Docmost wiki instances. Use it to read, create, update, search, and manage wiki content.
11
+
12
+ ## Prerequisites
13
+
14
+ The user must have `docmost-cli` installed and configured (`docmost-cli config init`). Test with `docmost-cli config test` if unsure.
15
+
16
+ ## Command Reference
17
+
18
+ ### Reading Content
19
+
20
+ ```bash
21
+ # List all spaces
22
+ docmost-cli space list --json
23
+
24
+ # List pages in a space
25
+ docmost-cli page list <space-slug> --json
26
+
27
+ # Get page content as Markdown
28
+ docmost-cli page get <page-id>
29
+
30
+ # Get page with YAML frontmatter (id, title, space, dates)
31
+ docmost-cli page get <page-id> --meta
32
+
33
+ # Search across all pages
34
+ docmost-cli search query "<search-term>" --json
35
+
36
+ # Search within a specific space
37
+ docmost-cli search query "<search-term>" --space <space-slug> --json
38
+
39
+ # Show page tree structure
40
+ docmost-cli page list <space-slug> --tree
41
+ ```
42
+
43
+ ### Writing Content
44
+
45
+ ```bash
46
+ # Create a page from inline Markdown
47
+ docmost-cli page create <space-slug> --title "Page Title" --content "# Heading\n\nContent here"
48
+
49
+ # Create a page from a file
50
+ docmost-cli page create <space-slug> --title "Page Title" --file content.md
51
+
52
+ # Update page title
53
+ docmost-cli page update <page-id> --title "New Title"
54
+
55
+ # Delete a page (use -y to skip confirmation)
56
+ docmost-cli -y page delete <page-id>
57
+ ```
58
+
59
+ ### Other Operations
60
+
61
+ ```bash
62
+ # Show current user info
63
+ docmost-cli user me
64
+
65
+ # Show workspace details
66
+ docmost-cli workspace info
67
+
68
+ # Add a comment to a page
69
+ docmost-cli comment create <page-id> --content "Comment text"
70
+
71
+ # List comments on a page
72
+ docmost-cli comment list <page-id> --json
73
+
74
+ # Export a page
75
+ docmost-cli page export <page-id> --format md
76
+ ```
77
+
78
+ ## Workflow Patterns
79
+
80
+ ### Finding and Reading a Page
81
+
82
+ 1. List spaces: `docmost-cli space list --json`
83
+ 2. Find the space slug you need
84
+ 3. Search or list pages: `docmost-cli search query "topic" --json`
85
+ 4. Read the page: `docmost-cli page get <page-id>`
86
+
87
+ ### Creating Documentation for Code
88
+
89
+ 1. Analyze the code the user wants documented
90
+ 2. Write Markdown content
91
+ 3. Save to a temp file or use `--content` flag
92
+ 4. Create the page: `docmost-cli page create <space-slug> --title "Title" --content "..."`
93
+ 5. Report the page ID back to the user
94
+
95
+ ### Updating Existing Documentation
96
+
97
+ 1. Get current content: `docmost-cli page get <page-id>`
98
+ 2. Modify the Markdown content as needed
99
+ 3. Update: `docmost-cli page update <page-id> --title "Updated Title"`
100
+ 4. Note: Content update via REST may not be available on Community edition
101
+
102
+ ## Output Format
103
+
104
+ - **Content commands** (`page get`): Raw Markdown to stdout — directly usable
105
+ - **List commands** (`--json`): JSON array — parse with standard JSON tools
106
+ - **Write commands** (`page create`, `delete`): Page ID to stdout, confirmation to stderr
107
+ - **Always use `--json`** for list/search commands when you need to parse the output programmatically
108
+
109
+ ## Tips
110
+
111
+ - Use `--json` flag on list commands to get parseable output
112
+ - Page IDs are UUIDs like `019a2a69-xxxx-xxxx-xxxx-xxxxxxxxxxxx`
113
+ - Space slugs are lowercase alphanumeric (e.g., `engineering`, `devtest`)
114
+ - Use `-y` flag to skip confirmation prompts for automated workflows
115
+ - Use `--verbose` for debugging connectivity issues
116
+
117
+ For detailed examples, see [examples.md](examples.md).
@@ -0,0 +1,85 @@
1
+ # Docmost Skill Examples
2
+
3
+ ## Example 1: Read wiki docs to inform implementation
4
+
5
+ User says: "Check the wiki for our API authentication docs"
6
+
7
+ ```bash
8
+ # Search for relevant pages
9
+ docmost-cli search query "authentication" --json
10
+
11
+ # Read the page content
12
+ docmost-cli page get 019a2a69-xxxx --meta
13
+ ```
14
+
15
+ ## Example 2: Create documentation from code
16
+
17
+ User says: "Document the payment module in our engineering wiki"
18
+
19
+ ```bash
20
+ # Create the page with generated Markdown
21
+ docmost-cli page create engineering --title "Payment Module" --content "# Payment Module
22
+
23
+ ## Overview
24
+ The payment module handles all billing operations...
25
+
26
+ ## API Endpoints
27
+ - POST /payments/create
28
+ - GET /payments/:id
29
+
30
+ ## Configuration
31
+ Set STRIPE_KEY in environment variables."
32
+ ```
33
+
34
+ ## Example 3: Backup all pages in a space
35
+
36
+ ```bash
37
+ # Get all page IDs
38
+ docmost-cli page list engineering --json
39
+
40
+ # For each page, export to file
41
+ docmost-cli page export <page-id> --format md --output backup/<page-id>.md
42
+ ```
43
+
44
+ ## Example 4: Search and summarize
45
+
46
+ User says: "What does our wiki say about deployment?"
47
+
48
+ ```bash
49
+ # Search
50
+ docmost-cli search query "deployment" --json
51
+
52
+ # Read each relevant result
53
+ docmost-cli page get <id-1>
54
+ docmost-cli page get <id-2>
55
+ ```
56
+
57
+ Then summarize the findings for the user.
58
+
59
+ ## Example 5: Create a page from a file in the repo
60
+
61
+ User says: "Publish our README to the wiki"
62
+
63
+ ```bash
64
+ docmost-cli page create engineering --title "Project README" --file README.md
65
+ ```
66
+
67
+ ## Example 6: Browse space structure
68
+
69
+ ```bash
70
+ # See the full page hierarchy
71
+ docmost-cli page list engineering --tree
72
+
73
+ # List child pages of a specific page
74
+ docmost-cli page children <parent-id> --json
75
+ ```
76
+
77
+ ## Example 7: Add review comments to a page
78
+
79
+ ```bash
80
+ # Add a comment
81
+ docmost-cli comment create <page-id> --content "Reviewed by Claude Code - looks good, minor typo in section 3"
82
+
83
+ # List existing comments
84
+ docmost-cli comment list <page-id> --json
85
+ ```
@@ -0,0 +1,52 @@
1
+ # Python bytecode / cache
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # Distribution / packaging
7
+ dist/
8
+ build/
9
+ *.egg-info/
10
+ *.egg
11
+ .eggs/
12
+
13
+ # Virtual environments
14
+ .venv/
15
+ venv/
16
+ ENV/
17
+ env/
18
+
19
+ # Testing / coverage
20
+ .pytest_cache/
21
+ .coverage
22
+ .coverage.*
23
+ htmlcov/
24
+ coverage.xml
25
+
26
+ # Type checking / linting
27
+ .mypy_cache/
28
+ .ruff_cache/
29
+
30
+ # C extensions
31
+ *.so
32
+
33
+ # IDE / editor
34
+ .vscode/
35
+ .idea/
36
+ *.swp
37
+ *.swo
38
+ *~
39
+
40
+ # OS files
41
+ .DS_Store
42
+ Thumbs.db
43
+ Desktop.ini
44
+
45
+ # Claude Code local settings (keep skills/ committed for team use)
46
+ .claude/*
47
+ !.claude/skills/
48
+
49
+ # Environment / secrets
50
+ .env
51
+ .env.*
52
+ config.toml
@@ -0,0 +1,102 @@
1
+ # Changelog
2
+
3
+ ## 0.4.0 (2026-03-22)
4
+
5
+ - Add `sync pull` command: download all pages from a space to local Markdown files with YAML frontmatter
6
+ - Add `sync push` command: upload local changes to server (create, update, move pages)
7
+ - Add `sync status` command: show changes between local files and last-pulled state
8
+ - Edition-aware content updates: Enterprise uses REST content update (preserves page ID), Community uses safe create-then-delete (new page created and verified before old page removed)
9
+ - Flat directory layout with `.docmost-manifest.json` tracking sync state and SHA-256 content hashes
10
+ - `--dry-run` flag on push to preview changes without executing
11
+ - `--delete` flag on push to remove server pages not found locally (opt-in safety)
12
+ - `--force` flag on pull to overwrite existing synced data
13
+ - Topological sort ensures parent pages are created before children
14
+ - ID remapping: when Community edition forces new page IDs, frontmatter and manifest are updated automatically
15
+ - 105 new tests (96 sync module + 9 CLI integration)
16
+
17
+ ## 0.3.1 (2026-03-22)
18
+
19
+ - Fix `page list --tree` and `page children` on Community edition: use `/pages/sidebar-pages` instead of `/pages/children` (404 on v0.70.3)
20
+ - Tree recursion: only fetch children for pages with `hasChildren: true` (eliminates ~40 wasted API calls on a 50-page space)
21
+ - Narrow error handling in tree builder (auth failures no longer silently swallowed)
22
+ - Reduce API calls in `page get` (fetch page info once, not twice)
23
+ - Remove raw HTTP call from CLI layer (use API function instead)
24
+ - Deduplicate UTF-8 stdio reconfigure into `_ensure_utf8_stdio()`
25
+ - Use `build_body` helper consistently in all API functions
26
+ - Remove dead code: unused models, unused parameter
27
+
28
+ ## 0.3.0 (2026-03-22)
29
+
30
+ - Add `parentPageId` to `page list --json` output columns
31
+ - Add `parent_id` to `page get --meta` YAML frontmatter
32
+ - Add `--icon` flag to `page update` command
33
+ - Add recursive tree fallback: `page list --tree` fills in missing children
34
+ - Add "See also" cross-references to all page command help text
35
+ - Fix `page children` and `--tree` on Community edition: use `/pages/sidebar-pages` instead of `/pages/children` (404 on v0.70.3)
36
+ - Fix emoji/Unicode crash: move UTF-8 encoding to correct entry point
37
+ - Fix `--parent` on `page create`: use fractional index position string
38
+ - Fix `--content` escape sequences: `\n` and `\t` now work as newline/tab
39
+
40
+ ## 0.2.4 (2026-03-22)
41
+
42
+ - Fix emoji/Unicode crash for real: move UTF-8 reconfigure from `__main__.py` to `cli/main.py` (the actual entry point used by `docmost-cli` script bypasses `__main__.py`)
43
+
44
+ ## 0.2.3 (2026-03-22)
45
+
46
+ - Fix `--parent` on `page create`: send fractional index position string (Docmost requires 5-12 char string, not integer)
47
+ - Fix emoji crash on all Windows terminals: remove `isatty()` guard, always reconfigure to UTF-8 on Windows
48
+ - Fix `--content` escape sequences: `\n` and `\t` now interpreted as actual newline/tab
49
+ - Position parameter on `page move` changed from `int` to `str` (fractional index format)
50
+
51
+ ## 0.2.2 (2026-03-22)
52
+
53
+ - Fix `--parent` on `page create` silently ignored (import endpoint ignores parentPageId; now calls move_page as fallback)
54
+ - Fix `--help` crash on Windows (`OSError` from Rich's LegacyWindowsRenderer on cp1252 consoles)
55
+ - Fix `page get --meta` crash when page content contains emoji (✅❌⚠️📊)
56
+ - Reconfigure stdout/stderr to UTF-8 at startup on Windows interactive terminals
57
+
58
+ ## 0.2.1 (2026-03-22)
59
+
60
+ - Fix tree view crash on Windows with emoji page icons (cp1252 encoding)
61
+ - Fix silent Enterprise endpoint probe leaking error messages on Community edition
62
+ - Fix API endpoints discovered during live integration testing:
63
+ - `/spaces/list` → `/spaces`
64
+ - `/comments/list` → `/comments`
65
+ - `/pages/export` format `md` → `markdown`, response is ZIP not JSON
66
+ - Auth token extracted from `authToken` cookie (not `token`)
67
+ - Comment content JSON-stringified for API
68
+ - Consolidate duplicated code: shared `extract_items`, `extract_id`, `build_body` helpers
69
+ - Remove 6 dead stub files (-84 lines)
70
+ - Add `post_raw()` to DocmostClient for binary/probe responses
71
+ - Fix double file read in page import
72
+ - Add Claude Code skill (`/docmost`) for wiki interaction
73
+ - Prepare for PyPI: py.typed marker, CHANGELOG, dependency upper bounds, classifiers
74
+
75
+ ## 0.2.0 (2026-03-22)
76
+
77
+ - Retry with exponential backoff for transient errors (429, 5xx)
78
+ - `--verbose` HTTP debug logging (request/response to stderr)
79
+ - Page duplicate, copy, children, history, export, import commands
80
+ - Tree view (`--tree`) for page listing
81
+ - Workspace info/members, user me, attachment search commands
82
+ - Pagination auto-follow with safety guard (max 1000 iterations)
83
+ - ProseMirror-to-Markdown converter (all block nodes and marks)
84
+ - Claude Code skill (`/docmost`) for wiki interaction
85
+ - Comprehensive README with command reference
86
+ - MIT LICENSE file
87
+ - Session cache file permissions (0600)
88
+ - 175 tests, 0 lint errors
89
+
90
+ ## 0.1.0 (2026-03-22)
91
+
92
+ - Initial release
93
+ - Project scaffolding with typer CLI framework
94
+ - Configuration system with TOML profiles and environment variable overrides
95
+ - HTTP client with API key (Enterprise) and session (Community) auth auto-detection
96
+ - Page CRUD: create (via import endpoint), read, update, delete, move
97
+ - Space list, create, update
98
+ - Comment list, create, update (ProseMirror JSON wrapping)
99
+ - Full-text search with space filtering
100
+ - Output helpers enforcing stdout/stderr separation
101
+ - Edition-agnostic design (Community + Enterprise)
102
+ - 50 tests with pytest + pytest-httpx
@@ -0,0 +1,117 @@
1
+ # CLAUDE.md — Project Instructions for Claude Code
2
+
3
+ ## Project
4
+
5
+ This is `docmost-cli`, a Python CLI tool for managing Docmost wiki instances from the terminal.
6
+ Read `SPECIFICATION.md` for the full project specification, API endpoints, command structure, and architecture.
7
+
8
+ ## Tech Stack
9
+
10
+ - Python ≥ 3.11, using `typer`, `httpx`, `rich`, `pydantic-settings`
11
+ - Package manager: `uv` preferred, `pip` as fallback
12
+ - Test framework: `pytest` with `pytest-httpx` for HTTP mocking
13
+
14
+ ## Development Commands
15
+
16
+ ```bash
17
+ # Install in dev mode
18
+ uv pip install -e ".[dev]"
19
+
20
+ # Run the CLI
21
+ python -m docmost_cli
22
+ # or after install:
23
+ docmost-cli
24
+
25
+ # Run tests
26
+ pytest
27
+
28
+ # Run tests with coverage
29
+ pytest --cov=docmost_cli
30
+
31
+ # Type checking
32
+ mypy src/
33
+
34
+ # Linting
35
+ ruff check src/ tests/
36
+ ruff format src/ tests/
37
+ ```
38
+
39
+ ## Code Style
40
+
41
+ - Use type hints everywhere (Python 3.11+ syntax, e.g. `str | None` not `Optional[str]`)
42
+ - Docstrings on all public functions (Google style)
43
+ - Keep CLI commands thin — business logic lives in `api/` and `convert/` modules
44
+ - Use pydantic models for all API request/response types
45
+ - `httpx.Client` should be created once and reused (connection pooling)
46
+ - All API calls go through `DocmostClient` — never raw httpx in the CLI layer
47
+ - Use `__all__` exports in `__init__.py` files
48
+
49
+ ## Architecture Rules
50
+
51
+ ```
52
+ cli/ → depends on api/, sync/, output/ (never the reverse)
53
+ api/ → depends on models/, config/ (never on cli/)
54
+ sync/ → depends on api/, output/ (manifest, frontmatter, diff are standalone)
55
+ convert/ → standalone (no internal dependencies)
56
+ output/ → formats data only (no API calls, no business logic)
57
+ enforces stdout/stderr separation
58
+ models/ → standalone pydantic models (no dependencies)
59
+ config/ → standalone (no dependencies except pydantic)
60
+ ```
61
+
62
+ ## Testing Approach
63
+
64
+ - **Conversion tests**: ProseMirror ↔ Markdown using fixture files in `tests/fixtures/`
65
+ - **API tests**: Mock HTTP responses with `pytest-httpx`
66
+ - **CLI tests**: Use typer's `CliRunner` for end-to-end command testing
67
+ - **Fixture pairs**: Every `.json` fixture has a matching `.md` expected output
68
+
69
+ ## Important Patterns
70
+
71
+ - **Auth auto-detection**: Check for `api_key` first, then fall back to `email`+`password`
72
+ - **ProseMirror content**: Always convert to Markdown for display; use `--raw` for JSON
73
+ - **Pagination**: Cursor-based. Auto-follow until exhausted unless `--limit` is set
74
+ - **Error handling**: Catch `httpx` exceptions → translate to user-friendly messages via `rich`
75
+ - **Confirmations**: Destructive operations prompt unless `--yes` / `-y` is passed
76
+ - **Page creation**: Prefer the import endpoint (server-side MD→ProseMirror) over client-side conversion
77
+
78
+ ### Output Strategy (no global `--json` flag)
79
+
80
+ The CLI follows Unix stdout/stderr separation. There is no global `--json` flag.
81
+ Each command category uses the format that fits its data shape:
82
+
83
+ | Command type | stdout | stderr | Example |
84
+ |---|---|---|---|
85
+ | **Content** (`page get`) | Raw Markdown | nothing | `docmost-cli page get abc123 > page.md` |
86
+ | **Content + meta** (`page get --meta`) | YAML frontmatter + Markdown | nothing | Parseable by any frontmatter tool |
87
+ | **Lists** (`page list`, `search`, ...) | Rich table (default) or JSON array (`--json`) | nothing | `docmost-cli page list eng --json \| jq` |
88
+ | **Writes** (`page create`, `delete`, ...) | Resource ID only | Confirmation message | `ID=$(docmost-cli page create ...)` |
89
+ | **Sync status** (`sync status`) | Change summary | nothing | `docmost-cli sync status eng` |
90
+ | **Sync push dry-run** (`sync push --dry-run`) | Action plan | nothing | `docmost-cli sync push eng --dry-run` |
91
+ | **Sync ops** (`sync pull`, `sync push`) | nothing | Progress + summary | `docmost-cli sync pull eng --dir ./docs/` |
92
+ | **Errors** | nothing | Error message | Exit codes: 0=ok, 1=error, 3=auth, 4=not-found |
93
+
94
+ This means:
95
+ - `docmost-cli page get <id>` output is directly pipeable as Markdown
96
+ - `docmost-cli page list <space> --json` is directly parseable by jq or Claude Code
97
+ - `PAGE_ID=$(docmost-cli page create ...)` captures just the ID with no extra parsing
98
+ - Human-readable messages never pollute captured output
99
+
100
+ ## Key Reference Files
101
+
102
+ - `SPECIFICATION.md` — Full project spec (commands, API endpoints, architecture)
103
+ - `src/docmost_cli/api/client.py` — Central HTTP client, auth logic
104
+ - `src/docmost_cli/convert/` — ProseMirror ↔ Markdown converters
105
+ - `tests/fixtures/` — ProseMirror JSON + expected Markdown pairs
106
+ - `man/man1/` — Man pages in groff format (one hub + one per command group)
107
+
108
+ ## When Starting a New Feature
109
+
110
+ 1. Check `SPECIFICATION.md` section 4 for the command signature
111
+ 2. Check `SPECIFICATION.md` section 5.2 for the API endpoint
112
+ 3. Create/update the pydantic model in `models/`
113
+ 4. Implement the API method in `api/`
114
+ 5. Wire up the CLI command in `cli/`
115
+ 6. Add tests (API mock + CLI runner)
116
+ 7. Update the implementation phases checklist in `SPECIFICATION.md`
117
+ 8. Update the corresponding man page in `man/man1/`