Skip to content

feat(docs): support html5-block reference map roundtrip#1380

Merged
SunPeiYang996 merged 1 commit into
mainfrom
codex/html5-block-resources
Jul 21, 2026
Merged

feat(docs): support html5-block reference map roundtrip#1380
SunPeiYang996 merged 1 commit into
mainfrom
codex/html5-block-resources

Conversation

@SunPeiYang996

@SunPeiYang996 SunPeiYang996 commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Support <html5-block path=\"@relative.html\"></html5-block> packaging and fetch-time large HTML materialization under doc-fetch-resources.

Summary by CodeRabbit

  • New Features

    • HTML5 block support for create/update/fetch with reference-map handling and local path linking.
  • Bug Fixes

    • Failure outputs preserve raw HTML/markup and emit explicit partial-failure envelopes (ok=false).
  • Documentation

    • Updated examples and guidance for HTML5 blocks, reference-map usage, and best practices.
  • Tests

    • Added end-to-end and unit tests covering HTML5 block flows and fetch behavior.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds HTML5-block support across docs v2 create/update/fetch flows: runtime raw partial-failure output, HTML5-block parsing/rewriting and reference_map handling, hidden write-input flags and request-body wiring, fetch post-processing with externalization, tests, and updated documentation.

Changes

HTML5 Block Support for Document Commands

Layer / File(s) Summary
Raw partial-failure output and AI result handling
shortcuts/common/runner.go, shortcuts/doc/docs_ai_result.go
Added OutRawPartialFailure method to emit unescaped JSON partial-failure envelopes and introduced AI result detection that routes docs AI outputs through raw partial-failure or normal raw output based on data["result"].
HTML5 block resource handling and transformation
shortcuts/doc/html5_block_resources.go
Implements html5-block constants/regexes, write-input resolution (--input vs --content+--reference-map), prepareHTML5BlockWriteContent that rewrites start tags to data-ref, populates/compacts reference_map, validates tag body (markdown-fence-aware), loads path="@..." files safely, externalizes large data to .html files, and marshals reference_map JSON without HTML escaping.
Create command v2 wiring for HTML5 blocks
shortcuts/doc/docs_create_v2.go
Adds hidden --input and --reference-map flags, validates/resolves write-input, prefers buildCreateBodyWithHTML5ReferenceMap for request bodies (dry-run fallback), and emits results via outDocsAIResult.
Update command v2 wiring for HTML5 blocks
shortcuts/doc/docs_update_v2.go
Adds hidden --input/--reference-map, makes validateUpdateV2 write-input-aware (hasWriteInput), enforces per-command require/reject rules, resolves write input when present, and builds update bodies with HTML5 reference-map support (dry-run fallback) before calling API and using outDocsAIResult.
Fetch command v2 post-processing for HTML5 blocks
shortcuts/doc/docs_fetch_v2.go
Adds extra_param to request body to request HTML5 block data, and post-processes fetched documents with processHTML5BlockReferenceMapForFetch to validate data-ref presence, externalize oversized HTML to files, and resolve path entries into inline data.
Comprehensive HTML5 block test suite
shortcuts/doc/html5_block_resources_test.go, shortcuts/doc/docs_fetch_v2_test.go
End-to-end tests covering flag behavior, path->data rewriting, input round-trips, validation errors (missing refs, reserved attrs, unreadable paths, inline-content conflicts), fetch externalization thresholds, markdown code-fence handling, AI failure raw output behavior, and helpers for stubbing/decoding requests.
User and developer guidance for HTML5 blocks
skills/lark-doc/SKILL.md, skills/lark-doc/references/lark-doc-*.md
Adds quick-decision rule requiring reading fetched HTML5 reference_map entries, updates create/fetch/update/XML docs with examples and parameter explanations for --input and --reference-map, and documents html5-block usage and constraints.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • larksuite/cli#638: Extends the v2 docs AI output/error path by adding RuntimeContext.OutRawPartialFailure and using it from the docs AI result emitter, related to prior raw-output and HTML-escaping changes.
  • larksuite/cli#1291: Overlaps with v2 docs create/update flow refactors and may touch similar flag/validation/execute paths.

Suggested labels

size/XL, feature

Suggested reviewers

  • fangshuyu-768

Poem

🐰 I hop through docs with careful cheer,

Rewriting blocks so HTML's clear.
Paths become refs, and refs become files,
Tests keep each round-trip free of trials.
Hooray — the CLI keeps content near!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.35% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description only includes a brief Summary and omits the required Changes, Test Plan, and Related Issues sections from the template. Add the missing sections with the main changes, validation steps, and related issue links or 'None' to match the repository template.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main feature: adding support for html5-block reference map roundtrip in the docs system.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/html5-block-resources

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added domain/ccm PR touches the ccm domain size/L Large or sensitive change across domains or core paths labels Jun 10, 2026
@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@1b83ff40edb35e0586b455465b25e7e2008f0f14

🧩 Skill update

npx skills add larksuite/cli#codex/html5-block-resources -y -g

@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.05%. Comparing base (c876841) to head (1b83ff4).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1380   +/-   ##
=======================================
  Coverage   75.05%   75.05%           
=======================================
  Files         901      901           
  Lines       95391    95391           
=======================================
  Hits        71591    71591           
  Misses      18307    18307           
  Partials     5493     5493           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 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/doc/html5_block_resources_test.go`:
- Around line 305-306: Replace the substring-based assertion on err with typed
assertions: use errs.ProblemOf(err) to assert the problem-level fields (e.g.,
Category/Subtype match the expected "reference_map.html5-block.html5_1"), and
use errors.As(err, &ve) into a *errs.ValidationError (variable name like ve) to
assert Param equals the expected parameter and that the underlying cause is
preserved (compare ve.Cause or unwrap(err) to the original cause). Apply the
same pattern for the other checks in this test file (the cases around the checks
at the other mentioned locations) instead of relying on err.Error() substring
matching.

In `@shortcuts/doc/html5_block_resources.go`:
- Around line 187-189: The error message format string passed to
common.ValidationErrorf is missing its format argument; update the call in the
block that checks `out == nil` so the format string receives `label` (i.e., pass
`label` as an argument to common.ValidationErrorf("%s must be a JSON object",
label) while keeping the existing .WithParam(label) usage) so the formatted
message prints the label instead of `%!s(MISSING)`.

In `@skills/lark-doc/references/lark-doc-xml.md`:
- Around line 52-74: The heading "### HTML5 block / 外部 HTML" is using an h3 and
breaks the document hierarchy after the h1 "三、资源块"; change that heading marker
to h2 (use "## HTML5 block / 外部 HTML") so the section correctly nests under the
top-level resource section and preserves proper heading structure in the
document.
🪄 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: aa3f74cb-27fa-4fd5-857e-bcd70b2ffab4

📥 Commits

Reviewing files that changed from the base of the PR and between 0d20a02 and c123880.

📒 Files selected for processing (12)
  • shortcuts/common/runner.go
  • shortcuts/doc/docs_ai_result.go
  • shortcuts/doc/docs_create_v2.go
  • shortcuts/doc/docs_fetch_v2.go
  • shortcuts/doc/docs_update_v2.go
  • shortcuts/doc/html5_block_resources.go
  • shortcuts/doc/html5_block_resources_test.go
  • skills/lark-doc/SKILL.md
  • skills/lark-doc/references/lark-doc-create.md
  • skills/lark-doc/references/lark-doc-fetch.md
  • skills/lark-doc/references/lark-doc-update.md
  • skills/lark-doc/references/lark-doc-xml.md

Comment thread shortcuts/doc/html5_block_resources_test.go
Comment thread shortcuts/doc/html5_block_resources.go Outdated
Comment thread skills/lark-doc/references/lark-doc-xml.md Outdated
@SunPeiYang996
SunPeiYang996 force-pushed the codex/html5-block-resources branch from c123880 to 86ecbd8 Compare June 11, 2026 08:01

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/doc/html5_block_resources.go`:
- Around line 500-510: The fence detection only checks for backtick fences and
ignores tilde fences, causing HTML5-block tags inside ~~~ blocks to be
processed; update the loop that iterates over strings.SplitAfter(content, "\n")
(the block that uses inFence, flush(), and out.WriteString) to trim the line
into a variable (e.g., trimmed := strings.TrimSpace(line)) and treat a line
starting with either "```" or "~~~" as a fence opener/closer (i.e., if
strings.HasPrefix(trimmed, "```") || strings.HasPrefix(trimmed, "~~~") then
toggle inFence and call flush() when opening); optionally improve robustness by
recording which fence char opened the block and require the same char to close
it.
🪄 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: 9ab82f18-c342-4d05-b076-eb36c40d6f77

📥 Commits

Reviewing files that changed from the base of the PR and between c123880 and 86ecbd8.

📒 Files selected for processing (13)
  • shortcuts/common/runner.go
  • shortcuts/doc/docs_ai_result.go
  • shortcuts/doc/docs_create_v2.go
  • shortcuts/doc/docs_fetch_v2.go
  • shortcuts/doc/docs_fetch_v2_test.go
  • shortcuts/doc/docs_update_v2.go
  • shortcuts/doc/html5_block_resources.go
  • shortcuts/doc/html5_block_resources_test.go
  • skills/lark-doc/SKILL.md
  • skills/lark-doc/references/lark-doc-create.md
  • skills/lark-doc/references/lark-doc-fetch.md
  • skills/lark-doc/references/lark-doc-update.md
  • skills/lark-doc/references/lark-doc-xml.md
💤 Files with no reviewable changes (5)
  • skills/lark-doc/references/lark-doc-fetch.md
  • skills/lark-doc/references/lark-doc-xml.md
  • skills/lark-doc/SKILL.md
  • skills/lark-doc/references/lark-doc-create.md
  • skills/lark-doc/references/lark-doc-update.md
🚧 Files skipped from review as they are similar to previous changes (6)
  • shortcuts/doc/docs_fetch_v2.go
  • shortcuts/doc/docs_ai_result.go
  • shortcuts/common/runner.go
  • shortcuts/doc/docs_create_v2.go
  • shortcuts/doc/html5_block_resources_test.go
  • shortcuts/doc/docs_update_v2.go

Comment thread shortcuts/doc/html5_block_resources.go
@SunPeiYang996
SunPeiYang996 force-pushed the codex/html5-block-resources branch from 86ecbd8 to 3b3c462 Compare June 11, 2026 10:07

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
skills/lark-doc/references/lark-doc-xml.md (1)

52-52: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix heading level to maintain proper document structure.

The heading jumps from h1 (line 39 "三、资源块") directly to h3. It should be h2 to maintain proper heading hierarchy.

📝 Proposed fix
-### HTML5 block / 外部 HTML
+## HTML5 block / 外部 HTML
🤖 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-doc/references/lark-doc-xml.md` at line 52, The heading "###
HTML5 block / 外部 HTML" is incorrectly at h3 and breaks the hierarchy after the
h1 "三、资源块"; change that heading from h3 to h2 (i.e., replace the leading "###"
with "##") so the section becomes "## HTML5 block / 外部 HTML" and restores proper
document structure.
🧹 Nitpick comments (1)
skills/lark-doc/references/lark-doc-xml.md (1)

114-119: 💤 Low value

Consider whether user citation documentation belongs in this PR.

These additions document user citation rules but appear unrelated to the HTML5-block feature this PR is adding. While the content is valuable documentation, bundling unrelated changes can complicate PR review and git history.

If this is intentional consolidation of documentation improvements, consider noting it in the PR description for clarity.

🤖 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-doc/references/lark-doc-xml.md` around lines 114 - 119, The new
"用户名写入规则" section in skills/lark-doc/references/lark-doc-xml.md is unrelated to
the HTML5-block feature in this PR; either move these user-citation
documentation changes into a separate documentation-only PR or clearly call out
in this PR description that it intentionally includes unrelated docs, so
reviewers know it’s deliberate; locate the "## 用户名写入规则" heading and extract or
split those bullet points into their own commit/PR or add a note to the PR
description explaining the consolidation.
🤖 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.

Duplicate comments:
In `@skills/lark-doc/references/lark-doc-xml.md`:
- Line 52: The heading "### HTML5 block / 外部 HTML" is incorrectly at h3 and
breaks the hierarchy after the h1 "三、资源块"; change that heading from h3 to h2
(i.e., replace the leading "###" with "##") so the section becomes "## HTML5
block / 外部 HTML" and restores proper document structure.

---

Nitpick comments:
In `@skills/lark-doc/references/lark-doc-xml.md`:
- Around line 114-119: The new "用户名写入规则" section in
skills/lark-doc/references/lark-doc-xml.md is unrelated to the HTML5-block
feature in this PR; either move these user-citation documentation changes into a
separate documentation-only PR or clearly call out in this PR description that
it intentionally includes unrelated docs, so reviewers know it’s deliberate;
locate the "## 用户名写入规则" heading and extract or split those bullet points into
their own commit/PR or add a note to the PR description explaining the
consolidation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 87ed256a-a62f-430d-82cf-1f8518eca837

📥 Commits

Reviewing files that changed from the base of the PR and between 86ecbd8 and 3b3c462.

📒 Files selected for processing (13)
  • shortcuts/common/runner.go
  • shortcuts/doc/docs_ai_result.go
  • shortcuts/doc/docs_create_v2.go
  • shortcuts/doc/docs_fetch_v2.go
  • shortcuts/doc/docs_fetch_v2_test.go
  • shortcuts/doc/docs_update_v2.go
  • shortcuts/doc/html5_block_resources.go
  • shortcuts/doc/html5_block_resources_test.go
  • skills/lark-doc/SKILL.md
  • skills/lark-doc/references/lark-doc-create.md
  • skills/lark-doc/references/lark-doc-fetch.md
  • skills/lark-doc/references/lark-doc-update.md
  • skills/lark-doc/references/lark-doc-xml.md
✅ Files skipped from review due to trivial changes (3)
  • skills/lark-doc/references/lark-doc-create.md
  • skills/lark-doc/references/lark-doc-fetch.md
  • skills/lark-doc/references/lark-doc-update.md
🚧 Files skipped from review as they are similar to previous changes (8)
  • shortcuts/doc/docs_fetch_v2_test.go
  • shortcuts/doc/docs_ai_result.go
  • shortcuts/common/runner.go
  • skills/lark-doc/SKILL.md
  • shortcuts/doc/docs_update_v2.go
  • shortcuts/doc/docs_create_v2.go
  • shortcuts/doc/html5_block_resources_test.go
  • shortcuts/doc/html5_block_resources.go

@SunPeiYang996
SunPeiYang996 force-pushed the codex/html5-block-resources branch from 3b3c462 to 1fe89f3 Compare June 30, 2026 08:33
@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown

PR Quality Summary

CI did not complete successfully. Use the failed check links below to decide whether this PR needs a code change or a rerun.

Failed checks

  • deterministic-gate — failure — details
  • results — failure — details

deterministic-gate

  • public_content_change_id_trailercommit:da237cc73ac6:3 — public contribution contains a Change-Id trailer — Action: remove the value from the public contribution and replace it with a non-sensitive placeholder

@SunPeiYang996
SunPeiYang996 force-pushed the codex/html5-block-resources branch 6 times, most recently from 711dfae to 29a284d Compare July 2, 2026 08:36
@github-actions github-actions Bot added size/M Single-domain feat or fix with limited business impact and removed size/L Large or sensitive change across domains or core paths labels Jul 2, 2026
@SunPeiYang996
SunPeiYang996 force-pushed the codex/html5-block-resources branch from 29a284d to da237cc Compare July 8, 2026 09:23
@SunPeiYang996
SunPeiYang996 force-pushed the codex/html5-block-resources branch 9 times, most recently from 53f4302 to 0942f5d Compare July 21, 2026 08:00
@SunPeiYang996
SunPeiYang996 force-pushed the codex/html5-block-resources branch 2 times, most recently from 51a6c71 to 7d752ca Compare July 21, 2026 08:43
@SunPeiYang996
SunPeiYang996 force-pushed the codex/html5-block-resources branch from 7d752ca to 1b83ff4 Compare July 21, 2026 08:48
@SunPeiYang996
SunPeiYang996 merged commit 990d633 into main Jul 21, 2026
41 checks passed
@SunPeiYang996
SunPeiYang996 deleted the codex/html5-block-resources branch July 21, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/ccm PR touches the ccm domain size/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants