feat(doc): add document word statistics helper - #1697
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a new ChangesDocument Word Stat Script
Estimated code review effort: 4 (Complex) | ~60 minutes Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@840959834e6f03c12dd3e59529f9b7a9348e27fb🧩 Skill updatenpx skills add larksuite/cli#feat/doc-word-stat-skill -y -g |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1697 +/- ##
==========================================
+ Coverage 74.47% 74.48% +0.01%
==========================================
Files 849 850 +1
Lines 86631 86703 +72
==========================================
+ Hits 64517 64583 +66
- Misses 17172 17175 +3
- Partials 4942 4945 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@skills/lark-doc/scripts/doc_word_stat.py`:
- Around line 1088-1090: The `--lark-json` handling in `doc_word_stat.py` is
assuming a fixed envelope shape and will crash with opaque parsing/key errors
when the payload is malformed or the content key is different. Update the
`args.lark_json` branch to validate the decoded object before reading
`envelope["data"]["document"]["content"]`, and surface a clear user-facing error
when the JSON is invalid or missing the expected keys. Keep the fix scoped to
the `json.loads`/envelope lookup path so the `source` assignment only proceeds
when the payload matches the expected lark-cli structure.
- Around line 629-639: The parse_xml function currently uses
xml.etree.ElementTree.fromstring on input that can come from stdin, files, or
docs +fetch, so harden this untrusted XML path by switching parse_xml to
defusedxml.ElementTree (including the fragment fallback) or add explicit
input/entity limits and trusted-input documentation. Update the XML parsing
logic in parse_xml and any related ET.parse/fromstring usage so the parser
cannot be abused with hostile XML content.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a75c62d1-6608-4cbc-aa1b-37df334bcbde
📒 Files selected for processing (2)
skills/lark-doc/SKILL.mdskills/lark-doc/scripts/doc_word_stat.py
|
Addressed the two CodeRabbit findings in baccac8:
Validation run locally:
|
b4e4c3b to
8409598
Compare
Summary
scripts/doc_word_stat.pyto the lark-doc skill for Docx/XML and Markdown word/character statisticsSKILL.mdlean with a route for word/character count requestsreferences/lark-doc-word-stat.mdwith the online-doc workflow, output interpretation, diagnostics guidance, and a concrete JSON exampleValidation
python3 skills/lark-doc/scripts/doc_word_stat.py -hpython3 -m py_compile skills/lark-doc/scripts/doc_word_stat.pynode scripts/skill-format-check/index.jsSummary by CodeRabbit
New Features
Documentation