Repository navigation
chore: bump plugin version to 0.2.0 - #12
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe plugin manifest version in Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Possibly related PRs
Poem
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #12 +/- ##
=======================================
+ Coverage 93.5% 93.7% +0.2%
=======================================
Files 10 10
Lines 1867 1993 +126
Branches 433 458 +25
=======================================
+ Hits 1746 1869 +123
+ Misses 33 31 -2
- Partials 88 93 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
* feat: move workspace to platform cache directory (#12) The per-document workspace previously lived in a .docx/<stem>/ folder next to the source file, cluttering user directories and risking collisions between same-named documents. It now lives under the platform user cache, in docx-editor/<hash>/ where <hash> is sha256 of the document's absolute path: Linux $XDG_CACHE_HOME/docx-editor (fallback ~/.cache/docx-editor) macOS ~/Library/Caches/docx-editor Windows %LOCALAPPDATA%\docx-editor (fallback ~/AppData/Local) The base directory can be overridden, in precedence order, by the workspace_dir argument to Document.open()/Workspace(), the DOCX_EDITOR_WORKSPACE_DIR environment variable, or the platform default. A relative override resolves against the source document's directory, so workspace_dir=".docx" reproduces the old next-to-file layout for debugging. Path resolution is centralized in Workspace._resolve_workspace_path(), replacing the duplicated logic in __init__, exists(), and delete(). Base directory cleanup suppresses OSError, since the base is now shared across documents and processes. No auto-migration: workspaces created by older versions are not found, and leftover .docx/ folders can be deleted. * fix: harden workspace cache path resolution and cleanup Follow-up to the cache migration, from a multi-reviewer pass. Crash: the workspace dir was keyed by sha256(str(path).encode()), but str(Path) carries undecodable filename bytes as surrogates, which strict UTF-8 rejects. Opening e.g. "café.docx" (latin-1 on disk) raised UnicodeEncodeError. Hash via os.fsencode(os.path.normcase(path)) instead; this is byte-identical for all decodable paths, so no workspace moves. normcase also folds case on Windows, where one file could otherwise map to two workspaces. Data loss: close()/delete() removed the base directory when it was left empty. That was safe when the base was the library's own .docx/ folder, but the base is now the shared cache root -- or whatever directory the caller passed via workspace_dir=/DOCX_EDITOR_WORKSPACE_DIR. The library was deleting a directory it did not create. It now removes only the document's own workspace folder. Two tests asserted the old behavior and are rewritten. Path resolution: overrides are now tilde-expanded (DOCX_EDITOR_WORKSPACE_DIR =~/ws created a literal "~" directory next to each document), an empty or whitespace override counts as unset and falls through to the next precedence level (workspace_dir="" silently rebased onto the document's own directory), and a relative XDG_CACHE_HOME/%LOCALAPPDATA% is ignored per the XDG spec rather than scattering caches beside every document. Permissions: the workspace holds the document's plaintext in a shared, predictably-named cache, so it and its base are created 0o700 instead of inheriting a 0o775 umask default. mkdir(parents=True, mode=) applies the mode to the leaf only, so the base is created explicitly. Provenance: a workspace whose meta.json names a different source document is now refused instead of silently adopted -- adopting it would let a later save() pack that other document's XML over this one's source file. Errors: filesystem failures at the new cache boundary (unwritable base, no resolvable home) surfaced as raw PermissionError/RuntimeError out of Document.open(). They are now WorkspaceError, naming the override to set. Also: add a public Document.workspace_path -- the docs told users to inspect the preserved workspace but gave them no way to locate it now that it is an opaque hash under the cache. Drop the write-only self.workspace_dir, hoist the function-local shutil import, and correct the "unsaved edits in the workspace" wording (edits reach the workspace only on save()). * fix: correct three regressions in the workspace hardening Found by a second adversarial pass over the previous commit. The permissions test guarded itself with skipif(os.getuid() == 0). A skipif condition is evaluated at collection time on every platform, and os.getuid does not exist on Windows, so the whole test module would die on import there -- taking with it the two tests that exist specifically to cover the Windows cache dir. Guard on os.name first; `or` short-circuits before os.geteuid. The provenance check compared the raw source path while the workspace key is normcase-folded. On a case-insensitive filesystem two spellings map to one workspace directory, which the check would then reject as "a different document" -- and the message tells the user to pass force_recreate=True, which would rmtree the workspace. Fold both sides the same way. Stripping the override with str(override).strip() also stripped Path inputs, silently redirecting a path that legitimately ends in whitespace to a different directory. Strip str overrides (where stray whitespace is config noise) and take a Path verbatim. Also document the WorkspaceError exits that the hardening added to Document.open(), and drop the literal ~ from the workspace_path example -- the value is always expanded.
Summary
.claude-plugin/plugin.jsonversion from0.1.1to0.2.0to match the release.Summary by CodeRabbit