feat(mail): HTML lint library + Larksuite-native autofix + lark-mail …#1019
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 mail HTML lint library with Feishu-native autofixes, shared ChangesHTML Linting for Mail Composition
Estimated code review effort 🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
✨ Finishing Touches🧪 Generate unit tests (beta)
|
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@c2dbf4acab6ce646922eaf47f364526258048f49🧩 Skill updatenpx skills add bubbmon233/cli#feat/mail-html-lint -y -g |
There was a problem hiding this comment.
Actionable comments posted: 10
🧹 Nitpick comments (2)
skill-template/domains/mail.md (1)
343-343: ⚡ Quick winInconsistency in shortcut count.
Line 343 describes "compose 5 shortcut" (
+send/+draft-create/+reply/+reply-all/+forward), but line 349 mentions 6 shortcuts by additionally including+draft-edit.The text should clarify whether
+draft-editis considered part of the "compose shortcuts" group or handle it separately, since it edits existing drafts rather than creating new ones.🤖 Prompt for 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. In `@skill-template/domains/mail.md` at line 343, The text is inconsistent about whether +draft-edit is part of the "compose shortcuts" group; update the copy to be explicit: either change "compose 5 shortcut" to "compose 6 shortcut" and include +draft-edit in the list (+send / +draft-create / +reply / +reply-all / +forward / +draft-edit), or keep "compose 5 shortcut" and move +draft-edit out of that list with a short clarifier that +draft-edit is a separate edit-op for existing drafts; update the sentence containing "compose 5 shortcut" and the nearby line that mentions +draft-edit so both reflect the chosen interpretation.skills/lark-mail/assets/templates/research--market-report.html (1)
10-34: ⚡ Quick win
<style>block is allowed by mail lint for LarkSuite-native rendering; inline-only is optional.This template’s
<style>(e.g.,skills/lark-mail/assets/templates/research--market-report.htmllines 10-34) won’t be stripped by+lint-html: the mail lint implementation explicitly treats<style>as “passed through verbatim”, while blocking/removing<script>,<iframe>, external<link>,on*handlers, andjavascript:URLs. Converting the classes to inline CSS is only necessary if the HTML must reliably render in non–LarkSuite email clients after forwarding outside the native mail editor.🤖 Prompt for 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. In `@skills/lark-mail/assets/templates/research--market-report.html` around lines 10 - 34, The <style> block in the template is currently preserved by our mail lint but may not render in non‑LarkSuite email clients; update the template (research--market-report.html) to ensure critical styles are applied inline for portability by converting key CSS rules from the .research-root, .gradient-header, .card, .stat-row, .stat-card, .player-row, .player-card, .callout-error, .tbl, .tbl-bug, .badge-*, and pri-p* classes into inline style attributes on the corresponding HTML elements (keep the existing <style> for native Lark rendering but add inline styles to elements that must render correctly when forwarded), making sure visual tokens like background-color, padding, border-radius, color, font-size, display, and box-shadow are mirrored inline.
🤖 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/mail/lint/linter.go`:
- Around line 758-761: In reorderAttrs remove the unused priority variable and
its initialization loop (the lines creating priority := make(map[string]int,
len(order)) and the for i, k := range order { priority[strings.ToLower(k)] = i +
1 }) since priority is never read; delete those lines and, if strings is now
unused, remove the strings.ToLower usage import or its import entry accordingly.
- Around line 1068-1077: The created inner wrapper (variable inner)
unconditionally sets dir="auto" and style="font-size:14px", which overrides
author-specified values; change the construction of inner so it first inspects
the source paragraph node's attributes (e.g., the original p node's Attr) and:
copy any existing dir attribute into inner instead of overriding it, merge style
attributes so existing font-size in the original style is preserved (only add
"font-size:14px" if no font-size is present), and preserve any other style
properties; in short, only apply the defaults for dir and font-size when they
are absent, otherwise reuse the original attributes.
- Around line 610-616: The code only maps margin- and padding- props to their
shorthands; update the switch that inspects prop (the block with
strings.HasPrefix checks that assigns shorthand) to also treat border shorthand
as satisfying border longhands by adding a branch that sets shorthand = "border"
when prop == "border" or strings.HasPrefix(prop, "border-"); this ensures an
existing "border" declaration prevents later autofixes from appending
border-left/right/top/bottom longhands.
In `@shortcuts/mail/mail_draft_edit.go`:
- Around line 38-40: Update the "--patch-file" description to remove the
absolute "MUST" requirement and clarify that incremental/editing operations must
use patch files while full replacements can use the new "--body" or
"--body-file" shortcuts; specifically, in the description associated with the
"patch-file" flag (referencing "set_body" and "set_reply_body"), state that
patch files are required for incremental body edits,
recipient/header/attachment/inline-image edits and for using "set_reply_body",
whereas "--body" and "bodyFileFlag" support full replacements (set_body) as an
alternative; keep guidance to run "--inspect" to check "has_quoted_content" and
"--print-patch-template" for the JSON structure.
In `@shortcuts/mail/mail_forward.go`:
- Around line 78-82: The validation currently only checks shape/mutex via
validateBodyFileMutex using bodyFlag := runtime.Str("body") and bodyFile :=
strings.TrimSpace(runtime.Str("body-file")), but doesn't resolve bodyFile
content before later compose validation; load/resolve the --body-file contents
here (e.g., read the file path validated by runtime.ValidatePath) into the body
variable and pass that resolved body to validateComposeInlineAndAttachments so
the same body value is seen in Validate as in Execute; keep existing calls to
validateBodyFileMutex and then replace the empty-body usage by the loaded body
when invoking validateComposeInlineAndAttachments.
In `@shortcuts/mail/mail_reply_all.go`:
- Around line 77-84: The code only checks that a --body-file path exists
(validateBodyFileMutex) but does not validate the resolved file contents,
allowing an empty file to bypass the required-body check; update the logic in
the handler where bodyFlag, bodyFile, bodyEmpty and hasTemplate are evaluated to
read and trim the contents of bodyFile when bodyFile != "" (similar to the +send
command pattern), set bodyEmpty based on the resolved content (not just the
flag), and return the same validation error via output.ErrValidation when the
resolved body is empty; reuse or extract the same helper used by +send for
resolving/validating file contents (or add a small helper) so compose/Execute
receives the validated, non-empty body string.
In `@shortcuts/mail/mail_reply.go`:
- Around line 76-83: The current check only inspects the --body-file path string
(bodyFile) and bodyFlag text, letting an empty/whitespace file pass; instead
resolve the file contents when a --body-file is provided and validate that
content before accepting it. In the block around bodyFlag :=
runtime.Str("body"), call the same file-read/resolve used by the send path
(i.e., replace or overwrite bodyFlag with the file contents when bodyFile != ""
and runtime.ValidatePath succeeds), then recompute bodyEmpty from the resolved
body text and run validateBodyFileMutex as before; this ensures Validate sees
the loaded reply body (not an empty filename) and prevents Execute from
receiving empty content. Ensure you update references to bodyFlag/bodyEmpty used
in the later Validate/Execute flow (and keep hasTemplate and the
output.ErrValidation check) so the required-body check uses the resolved body
string.
In `@shortcuts/mail/mail_send.go`:
- Around line 80-90: The validation currently treats a non-empty --body-file
path (bodyFile) as satisfying the required-body rule even if the file's contents
are empty/whitespace; after validateBodyFileMutex and after reading/resolving
the actual body content into the variable used to send the email (e.g., the
resolved `body` variable derived from bodyFlag or the file), re-evaluate the
required-body check using that resolved content (instead of bodyFile or
bodyFlag), so replace the bodyEmpty/bodyFile check with a trim/empty check
against the resolved `body` value (and do the same fix for the similar check
around lines 109-119).
In `@skills/lark-mail/references/lark-mail-reply.md`:
- Line 20: The trailing unmatched bold marker in the sentence "编辑邮件内容前 MUST 先用
Read 工具读取
[references/lark-mail-html.md](references/lark-mail-html.md),其中包含邮件书写规范**"
breaks Markdown; edit the line in skills/lark-mail/references/lark-mail-reply.md
to either remove the stray closing "**" or add a matching opening "**" around
the intended text so the bold markup is balanced and renders correctly.
In `@skills/lark-mail/references/lark-mail-send.md`:
- Line 15: Remove the unmatched trailing bold marker by editing the line that
currently reads "编辑邮件内容前 MUST 先用 Read 工具读取
[references/lark-mail-html.md](references/lark-mail-html.md),其中包含邮件书写规范**" in
skills/lark-mail/references/lark-mail-send.md; either delete the final "**" or
add the matching opening "**" to correctly wrap the intended bold text so the
Markdown bold markers are balanced.
---
Nitpick comments:
In `@skill-template/domains/mail.md`:
- Line 343: The text is inconsistent about whether +draft-edit is part of the
"compose shortcuts" group; update the copy to be explicit: either change
"compose 5 shortcut" to "compose 6 shortcut" and include +draft-edit in the list
(+send / +draft-create / +reply / +reply-all / +forward / +draft-edit), or keep
"compose 5 shortcut" and move +draft-edit out of that list with a short
clarifier that +draft-edit is a separate edit-op for existing drafts; update the
sentence containing "compose 5 shortcut" and the nearby line that mentions
+draft-edit so both reflect the chosen interpretation.
In `@skills/lark-mail/assets/templates/research--market-report.html`:
- Around line 10-34: The <style> block in the template is currently preserved by
our mail lint but may not render in non‑LarkSuite email clients; update the
template (research--market-report.html) to ensure critical styles are applied
inline for portability by converting key CSS rules from the .research-root,
.gradient-header, .card, .stat-row, .stat-card, .player-row, .player-card,
.callout-error, .tbl, .tbl-bug, .badge-*, and pri-p* classes into inline style
attributes on the corresponding HTML elements (keep the existing <style> for
native Lark rendering but add inline styles to elements that must render
correctly when forwarded), making sure visual tokens like background-color,
padding, border-radius, color, font-size, display, and box-shadow are mirrored
inline.
🪄 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: 62896bff-36f5-4ce8-b023-048faf73379c
📒 Files selected for processing (32)
shortcuts/mail/body_file.goshortcuts/mail/lint/linter.goshortcuts/mail/lint/linter_test.goshortcuts/mail/lint/rules.goshortcuts/mail/lint/types.goshortcuts/mail/mail_draft_create.goshortcuts/mail/mail_draft_create_test.goshortcuts/mail/mail_draft_edit.goshortcuts/mail/mail_forward.goshortcuts/mail/mail_lint_html.goshortcuts/mail/mail_lint_html_test.goshortcuts/mail/mail_lint_writepath.goshortcuts/mail/mail_lint_writepath_test.goshortcuts/mail/mail_reply.goshortcuts/mail/mail_reply_all.goshortcuts/mail/mail_send.goshortcuts/mail/shortcuts.goskill-template/domains/mail.mdskills/lark-mail/SKILL.mdskills/lark-mail/assets/templates/job-application--resume.htmlskills/lark-mail/assets/templates/newsletter--weekly-brief.htmlskills/lark-mail/assets/templates/research--market-report.htmlskills/lark-mail/assets/templates/weekly--personal-report.htmlskills/lark-mail/assets/templates/weekly--team-report.htmlskills/lark-mail/references/lark-mail-draft-create.mdskills/lark-mail/references/lark-mail-draft-edit.mdskills/lark-mail/references/lark-mail-forward.mdskills/lark-mail/references/lark-mail-html.mdskills/lark-mail/references/lark-mail-lint-html.mdskills/lark-mail/references/lark-mail-reply-all.mdskills/lark-mail/references/lark-mail-reply.mdskills/lark-mail/references/lark-mail-send.md
9416637 to
f01a428
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
shortcuts/mail/mail_draft_edit.go (1)
74-75:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winUpdate stale “all body edits via patch-file” guidance in DryRun/template text.
These strings still instruct users to route all body edits through
--patch-file, which now contradicts supported behavior and can mislead automation.Suggested wording update
- Desc("Edit an existing draft without sending it: first call drafts.get(format=raw) to fetch the current EML, parse it into MIME structure, apply either direct flags or the typed patch from patch-file, re-serialize the updated draft, and then call drafts.update. This is a minimal-edit pipeline rather than a full rebuild, so unchanged headers, attachments, and MIME subtrees are preserved where possible. Body edits must go through --patch-file using set_body or set_reply_body ops. It also has no optimistic locking, so concurrent edits to the same draft are last-write-wins."). + Desc("Edit an existing draft without sending it: first call drafts.get(format=raw) to fetch the current EML, parse it into MIME structure, apply either direct flags or the typed patch from patch-file, re-serialize the updated draft, and then call drafts.update. This is a minimal-edit pipeline rather than a full rebuild, so unchanged headers, attachments, and MIME subtrees are preserved where possible. For quick full replacement, use --body/--body-file (equivalent to set_body); use --patch-file for advanced/incremental body edits including set_reply_body. It also has no optimistic locking, so concurrent edits to the same draft are last-write-wins."). ... - "Use --patch-file for ALL body edits and advanced changes (recipients, headers, attachments, inline images)", + "Use --body/--body-file for quick full-body replacement; use --patch-file for advanced/incremental body edits and other changes (recipients, headers, attachments, inline images)",Also applies to: 590-593
🤖 Prompt for 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. In `@shortcuts/mail/mail_draft_edit.go` around lines 74 - 75, Update the stale description text in mail_draft_edit.go (the Desc string attached to the GET route for mailboxPath(mailboxID, "drafts", draftID)) to remove or reword the claim that "Body edits must go through --patch-file" so it matches current behavior; revise the DryRun/template wording similarly where the same guidance appears (also applies to the other occurrence around lines 590-593) and ensure the description still documents that edits preserve unchanged MIME parts and that the pipeline is minimal-edit/last-write-wins.
🤖 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-mail/references/lark-mail-draft-edit.md`:
- Around line 13-15: Update page-wide wording to reflect that the new flags
--body and --body-file expand to the set_body op and are mutually exclusive with
--patch-file and with set_body/set_reply_body inside patch files; find and
replace any remaining sentences or examples that assert "body edits must use
--patch-file" (including examples referencing --patch-file only) to instead
state that full-body replacement can be done via --body/--body-file, while
--patch-file remains for preserving quotes or composing finer-grained ops; keep
the CRITICAL note about using the Read tool to consult
references/lark-mail-html.md before editing and ensure cross-references
(set_body, set_reply_body, --patch-file) clearly state their mutual exclusivity
and when to use each option.
In `@skills/lark-mail/references/lark-mail-html.md`:
- Line 18: In the markdown sentence fragment
"**正文长度自适应**:不正文长度,但要求**首屏要见到关键信息**。", fix the typo by replacing "不正文长度" with
"不限制正文长度" so the guidance reads "**正文长度自适应**:不限制正文长度,但要求**首屏要见到关键信息**。; update
that exact sentence in lark-mail-html.md.
In `@skills/lark-mail/references/lark-mail-reply-all.md`:
- Line 16: The line containing "编辑邮件内容前 MUST 先用 Read 工具读取
[references/lark-mail-html.md](references/lark-mail-html.md),其中包含邮件书写规范**" has
an extra trailing bold marker; remove the stray trailing "**" (or add a matching
opening "**" if bolding was intended) so the Markdown bold markers are balanced
and the sentence renders correctly.
---
Outside diff comments:
In `@shortcuts/mail/mail_draft_edit.go`:
- Around line 74-75: Update the stale description text in mail_draft_edit.go
(the Desc string attached to the GET route for mailboxPath(mailboxID, "drafts",
draftID)) to remove or reword the claim that "Body edits must go through
--patch-file" so it matches current behavior; revise the DryRun/template wording
similarly where the same guidance appears (also applies to the other occurrence
around lines 590-593) and ensure the description still documents that edits
preserve unchanged MIME parts and that the pipeline is
minimal-edit/last-write-wins.
🪄 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: db6151c1-f423-453a-83cf-c97df611cadf
📒 Files selected for processing (32)
shortcuts/mail/body_file.goshortcuts/mail/lint/linter.goshortcuts/mail/lint/linter_test.goshortcuts/mail/lint/rules.goshortcuts/mail/lint/types.goshortcuts/mail/mail_draft_create.goshortcuts/mail/mail_draft_create_test.goshortcuts/mail/mail_draft_edit.goshortcuts/mail/mail_forward.goshortcuts/mail/mail_lint_html.goshortcuts/mail/mail_lint_html_test.goshortcuts/mail/mail_lint_writepath.goshortcuts/mail/mail_lint_writepath_test.goshortcuts/mail/mail_reply.goshortcuts/mail/mail_reply_all.goshortcuts/mail/mail_send.goshortcuts/mail/shortcuts.goskill-template/domains/mail.mdskills/lark-mail/SKILL.mdskills/lark-mail/assets/templates/job-application--resume.htmlskills/lark-mail/assets/templates/newsletter--weekly-brief.htmlskills/lark-mail/assets/templates/research--market-report.htmlskills/lark-mail/assets/templates/weekly--personal-report.htmlskills/lark-mail/assets/templates/weekly--team-report.htmlskills/lark-mail/references/lark-mail-draft-create.mdskills/lark-mail/references/lark-mail-draft-edit.mdskills/lark-mail/references/lark-mail-forward.mdskills/lark-mail/references/lark-mail-html.mdskills/lark-mail/references/lark-mail-lint-html.mdskills/lark-mail/references/lark-mail-reply-all.mdskills/lark-mail/references/lark-mail-reply.mdskills/lark-mail/references/lark-mail-send.md
✅ Files skipped from review due to trivial changes (5)
- skills/lark-mail/references/lark-mail-draft-create.md
- skills/lark-mail/references/lark-mail-forward.md
- skill-template/domains/mail.md
- skills/lark-mail/references/lark-mail-lint-html.md
- skills/lark-mail/references/lark-mail-reply.md
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1019 +/- ##
==========================================
+ Coverage 68.23% 68.61% +0.38%
==========================================
Files 617 625 +8
Lines 57176 58348 +1172
==========================================
+ Hits 39013 40035 +1022
- Misses 14933 15029 +96
- Partials 3230 3284 +54 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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/mail/lint/linter.go`:
- Around line 488-492: The inline comment documenting the <li> style is out of
sync with the actual autofix output: ensureFeishuListItemStyle emits
margin-top:0px and margin-bottom:0px but the comment shows 4px; update the
comment block for the <li> entry so it matches the real output
(margin-top:0px;margin-bottom:0px) or, if you intended the autofix to emit 4px,
change ensureFeishuListItemStyle instead — reference ensureFeishuListItemStyle
and the <li> style comment in the same file and make them consistent.
🪄 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: 2f95fd22-aefc-4e82-8301-0edf95bf7b79
📒 Files selected for processing (2)
shortcuts/mail/lint/linter.goshortcuts/mail/lint/rules.go
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 `@skills/lark-mail/references/lark-mail-draft-edit.md`:
- Line 17: The heading "正文编辑:快捷 flag 与 typed op 的选择" uses level 3 (`###`)
without a preceding level 2, causing MD001; to fix, either promote this heading
to level 2 (`##`) or add an appropriate `##` parent heading above it so the
document's heading sequence is incremental—locate the line containing "正文编辑:快捷
flag 与 typed op 的选择" and update the markdown heading level accordingly.
🪄 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: 61d33448-f023-4e39-a26b-3cd63094bcc6
📒 Files selected for processing (15)
shortcuts/mail/body_file.goshortcuts/mail/lint/linter.goshortcuts/mail/lint/linter_test.goshortcuts/mail/mail_draft_create.goshortcuts/mail/mail_draft_edit.goshortcuts/mail/mail_reply.goshortcuts/mail/mail_reply_all.goshortcuts/mail/mail_send.goshortcuts/mail/mail_shortcut_validation_test.goskills/lark-mail/references/lark-mail-draft-edit.mdskills/lark-mail/references/lark-mail-forward.mdskills/lark-mail/references/lark-mail-html.mdskills/lark-mail/references/lark-mail-reply-all.mdskills/lark-mail/references/lark-mail-reply.mdskills/lark-mail/references/lark-mail-send.md
✅ Files skipped from review due to trivial changes (4)
- skills/lark-mail/references/lark-mail-reply.md
- skills/lark-mail/references/lark-mail-reply-all.md
- skills/lark-mail/references/lark-mail-forward.md
- skills/lark-mail/references/lark-mail-html.md
🚧 Files skipped from review as they are similar to previous changes (7)
- skills/lark-mail/references/lark-mail-send.md
- shortcuts/mail/mail_send.go
- shortcuts/mail/mail_draft_edit.go
- shortcuts/mail/mail_draft_create.go
- shortcuts/mail/mail_reply.go
- shortcuts/mail/mail_reply_all.go
- shortcuts/mail/lint/linter.go
…skill 为 lark-cli mail 域写信链路引入 HTML lint 能力,提升邮件 HTML 的兼容性、 安全性与 Larksuite-native 格式适配。 lint 库(shortcuts/mail/lint/): - 四档分类:pass / native-autofix / warn-autofix / error-strip - 安全规则覆盖 script / iframe / on* 事件处理器 / javascript: 及其它 危险 URL scheme 等 XSS 向量,未知 scheme 一律删除并归 error - Larksuite-native 格式自动修复:双层 div 段落、原生多级列表结构、 灰边引用、Larksuite 蓝链接 - cleaned_html 输出确定性稳定(位置索引派生 data-ol-id),便于 golden-file 测试与缓存 +lint-html 独立预检 shortcut: - 只读、不调 API、不建草稿,供 AI / 用户 / CI 在写信前预览 lint 结果 写入路径内置 lint(6 个 compose shortcut): - +send / +draft-create / +draft-edit / +reply / +reply-all / +forward 在 emlbuilder 之前强制 lint 净化 HTML - 默认 envelope 对 lint 改动透明(无 lint 字段),保持小巧供 AI 消费; --show-lint-details 显式取证返回 lint_applied[] / original_blocked[] - --body-file 支持从文件读取 body(32MB 上限),与 --body 互斥 预制 HTML 邮件模板(skills/lark-mail/assets/templates/): - 资讯周报 / 个人周报 / 团队周报 / 调研报告 / 求职简历 5 套 - 按 Larksuite mail-editor 原生格式编写,含正确的多级列表嵌套结构 lark-mail skill 文档: - references/lark-mail-html.md:邮件 HTML 写法指南(24 个格式 section + 颜色调色盘 + URL scheme + 官方模板套用流程) - references/lark-mail-lint-html.md:+lint-html 用法 - SKILL.md 顶部 CRITICAL 引导
Drop the unused `readAttr` helper in shortcuts/mail/lint/linter.go that was flagged by golangci-lint (unused linter). Apply gofmt to linter.go and rules.go which had minor formatting issues.
6517b4d to
34e02ca
Compare
34e02ca to
c2dbf4a
Compare
Summary
为 lark-cli mail 域写信链路引入 HTML lint 能力:邮件 HTML 在进入投递前完成安全过滤与 Larksuite-native
格式适配,提升邮件的安全性、兼容性与渲染一致性。
Changes
shortcuts/mail/lint/):四档分类(pass / native-autofix / warn-autofix /error-strip),覆盖
script/iframe/on*事件处理器 / 危险 URL scheme 等 XSS向量,并将段落、列表、引用等自动修复为 Larksuite mail-editor 原生格式
+lint-html只读预检 shortcut,供 AI / 用户 / CI 在写信前预览 lint 结果+send/+draft-create/+draft-edit/+reply/+reply-all/+forward)在构造 eml 前强制执行 lint;默认 envelope 对 lint 改动透明,--show-lint-details输出lint_applied[]/original_blocked[]取证--body-file参数,支持从文件读取 HTML body(32MB 上限)references/lark-mail-html.md(HTML写法指南)、
references/lark-mail-lint-html.md(+lint-html用法)Test Plan
go build ./...与go test ./shortcuts/mail/...全部通过lark mail +send/+draft-create/+lint-html等命令符合预期(49 + 48 个 CLI端到端用例,含真实邮件渲染人工验证)
Related Issues
Summary by CodeRabbit
New Features
Documentation
Tests