feat: add markdown +patch shortcut#857
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:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughAdds ChangesMarkdown Patch Feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #857 +/- ##
==========================================
+ Coverage 66.47% 66.80% +0.32%
==========================================
Files 562 564 +2
Lines 51871 52465 +594
==========================================
+ Hits 34482 35048 +566
- Misses 14499 14516 +17
- Partials 2890 2901 +11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@5bdc5204f828dc32c7e9e952362bdcfdfced2eea🧩 Skill updatenpx skills add larksuite/cli#feat/markdown-patch -y -g |
Change-Id: I8159941ff9dec4e5cbf0c757ec19ee172b302224
762bf38 to
963a61d
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@shortcuts/markdown/markdown_patch.go`:
- Around line 184-189: The replacement is using regexp.ReplaceAllString which
treats $-sequences as capture references and can corrupt literal Markdown (e.g.,
"$100"); change the call to use re.ReplaceAllLiteralString(original,
spec.Content) so spec.Content is used verbatim. Locate the
regexp.Compile(spec.Pattern) block and replace the re.ReplaceAllString(...) call
(near re.FindAllStringIndex and return) with re.ReplaceAllLiteralString while
keeping the match counting via re.FindAllStringIndex(original, -1) and returning
len(matches) as before.
🪄 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: cb50732b-7ce0-4955-83ff-fa9b2d5ceb59
📒 Files selected for processing (14)
README.mdREADME.zh.mdshortcuts/markdown/helpers.goshortcuts/markdown/markdown_overwrite.goshortcuts/markdown/markdown_patch.goshortcuts/markdown/markdown_patch_test.goshortcuts/markdown/markdown_test.goshortcuts/markdown/shortcuts.goskills/lark-drive/SKILL.mdskills/lark-drive/references/lark-drive-upload.mdskills/lark-markdown/SKILL.mdskills/lark-markdown/references/lark-markdown-patch.mdtests/cli_e2e/markdown/markdown_dryrun_test.gotests/cli_e2e/markdown/markdown_workflow_test.go
✅ Files skipped from review due to trivial changes (6)
- skills/lark-markdown/references/lark-markdown-patch.md
- README.md
- skills/lark-drive/references/lark-drive-upload.md
- shortcuts/markdown/shortcuts.go
- skills/lark-markdown/SKILL.md
- README.zh.md
🚧 Files skipped from review as they are similar to previous changes (7)
- shortcuts/markdown/markdown_test.go
- tests/cli_e2e/markdown/markdown_workflow_test.go
- tests/cli_e2e/markdown/markdown_dryrun_test.go
- skills/lark-drive/SKILL.md
- shortcuts/markdown/helpers.go
- shortcuts/markdown/markdown_overwrite.go
- shortcuts/markdown/markdown_patch_test.go
53e3316 to
4d98eec
Compare
fangshuyu-768
left a comment
There was a problem hiding this comment.
Review Summary
Thanks for the PR! The +patch shortcut is a nice addition. Here are the issues I found:
| Priority | Issue | File |
|---|---|---|
| High | No HTTP status code check after download — error responses could be treated as Markdown and uploaded, corrupting the file | helpers.go |
| Medium | $ injection in regex replacement with no escape mechanism |
markdown_patch.go |
| Medium | Regex compiled twice (Validate + Execute) | markdown_patch.go |
| Medium | TOCTOU: no concurrency protection between download and upload | markdown_patch.go |
| Low | Inconsistent required-flag checking style | markdown_patch.go |
| Low | Download filename discarded then re-fetched via extra API call | markdown_patch.go |
| Low | match_count type roundtrip through float |
markdown_patch.go |
The High priority item (missing HTTP status check) could lead to data corruption and should be addressed before merge.
Change-Id: I98079901e980b74998938afc4917b91a79689948
4d98eec to
5bdc520
Compare
* feat: add markdown +patch shortcut Change-Id: I8159941ff9dec4e5cbf0c757ec19ee172b302224 * fix: align markdown patch validation and dry-run Change-Id: I98079901e980b74998938afc4917b91a79689948
Summary
Add a new
markdown +patchshortcut that updates a Markdown file in Drive via a fetch-local-replace-overwrite flow, enabling targeted edits without rewriting the entire file. Supports both literal and RE2 regex matching modes.Changes
shortcuts/markdown/markdown_patch.goimplementing themarkdown +patchcommand and register it inshortcuts/markdown/shortcuts.goshortcuts/markdown/helpers.goand refactormarkdown_overwrite.goto reuse themmarkdown_patch_test.gocovering literal/regex modes, zero-match skip-upload, and flag validationtests/cli_e2e/markdown/lark-markdownskill docs, and addskills/lark-markdown/references/lark-markdown-patch.mdTest Plan
make unit-test)lark markdown +patchcommand works as expected (literal, regex, and zero-match scenarios)Related Issues
Summary by CodeRabbit
New Features
Documentation
Tests