Feishu Wiki Tools
Read, write, optimize, upload local markdown, copy, sync, and export Feishu wiki pages.
Skill Files Location
This skill's supporting files are located relative to this SKILL.md:
scripts/feishu_tool.py — Self-contained Python script for read/write/info operations (needs only .env)
references/optimization-guide.md — Format comparison framework and known reference patterns
references/conservative-edits.md — Guidelines for light-touch editing
Prerequisites
Data Locations
- Token cache:
~/.config/feishu_tools/token_cache.json
- Sync state:
~/log/feishu_tools/sync_logs/state/
- Sync logs:
~/log/feishu_tools/sync_logs/ (one log per sync run)
Install dependencies on first run:
pip install requests python-dotenv 2>/dev/null
Arguments
$ARGUMENTS should be: ACTION [ARGS...]
Determine the action from the user's intent:
| User intent |
Action |
| Read/view/fetch a page |
read SOURCE_URL |
| Write/create/publish a page |
write PARENT_URL |
| Compare two pages |
diff LEFT_URL RIGHT_URL |
| Show page metadata |
info SOURCE_URL |
| Optimize/polish a page |
optimize SOURCE_URL DEST_URL |
| Upload a local markdown file |
upload MD_PATH PARENT_URL |
| Copy a page |
copy SOURCE_URL TARGET_URL |
| Sync pages |
sync SOURCE_URL TARGET_URL |
| Export to local files |
export SOURCE_URL |
upload command: /feishu upload [md_path] [parent_url]
md_path may be relative (resolved from current working directory) or absolute
parent_url is the Feishu wiki URL under which the new page will be created as a sub-page
Action: read
Read a Feishu wiki page and display its content as markdown.
python <skill-directory>/scripts/feishu_tool.py read SOURCE_URL
Options:
--no-title — Omit the H1 title from output
The script outputs clean markdown to stdout (logs go to stderr). Display the content to the user. If they ask follow-up questions, answer based on the retrieved text.
Notes
- On first run, it may prompt for OAuth authorization — follow the printed URL
- Token is cached in
~/.config/feishu_tools/token_cache.json for subsequent runs
- Supports docx-type wiki pages only
Action: diff
Read two Feishu wiki pages as markdown and print a unified diff.
python <skill-directory>/scripts/feishu_tool.py diff LEFT_URL RIGHT_URL
Options:
--no-title — omit the H1 title before diffing
--context N — control unified diff context size (default: 3)
--normalize — normalize markdown before diffing to reduce noisy differences
Recommended use:
- Compare a newly created page against a reference page before modifying the tool or skill
- Use
--normalize when you want to focus on substantive markdown structure differences rather than trivial separator normalization (e.g. Unicode dashes in table separator rows)
Action: info
Show page metadata.
python <skill-directory>/scripts/feishu_tool.py info SOURCE_URL
Prints: title, node token, obj token, obj type, space ID, has_child.
Action: write
Create a new Feishu wiki page from markdown content.
- Prepare the markdown content from the conversation or a file.
- Write the optimized content to a temp file, then upload:
# Step 1: Write content to a temp file
UPLOAD_TMP=$(mktemp /tmp/feishu_upload_XXXXXX.md)
cat > "$UPLOAD_TMP" << 'FEISHU_CONTENT_END'
## Section 1
Content here...
FEISHU_CONTENT_END
# Step 2: Upload from file
python <skill-directory>/scripts/feishu_tool.py write PARENT_URL \
--title "Page Title" \
--input-file "$UPLOAD_TMP"
# Step 3: Clean up
rm -f "$UPLOAD_TMP"
- The script prints the new page URL to stdout. Share this URL with the user.
Options
--heading-color — Auto-color heading backgrounds by relative depth: outermost → red/pink, then orange, yellow, green, blue, purple. Explicit {bg=N} on a heading always wins.
--input-file FILE / -f FILE — Read markdown from FILE instead of stdin. Preferred over heredoc for large documents (avoids shell escaping issues).
Inline formatting
| Syntax |
Result |
**text** |
Bold |
*text* |
Italic |
`code` |
Inline code |
~~text~~ |
Strikethrough |
[label](url) |
Link |
{red:text} |
🔴 Red text color — use liberally for key points (10–20× per document) |
{red:**text**} |
🔴 Red bold text — highest emphasis for critical conclusions |
{green:text} |
🟢 Green background highlight |
{green:**text**} |
🟢 Green highlight + bold — key concept first mention |
{yellow:text} |
🟡 Yellow background highlight |
{orange:text} |
🟠 Orange background highlight |
{blue:text} |
🔵 Blue background highlight |
{purple:text} |
🟣 Purple background highlight |
Notes
- New page is created as a child (sub-node) of the parent.
- If
--title is omitted, title is extracted from the first H1.
- Always use
<< 'FEISHU_CONTENT_END' (quoted delimiter) to prevent variable expansion in the temp file write step.
- The
--input-file approach avoids heredoc shell escaping issues (e.g. {red:...} markers containing {...} in LaTeX).
- Supported: headings, paragraphs, bold, italic, code, strikethrough, links, bullet/ordered lists, code blocks, blockquotes, dividers, tables (
| col | col | pipe format), callout blocks, quote containers (|> prefix), LaTeX equations, images.
- Images: Use
 in markdown. Pass --image-dir DIR to resolve relative image paths. Images are uploaded after block creation. If --image-dir is omitted, image lines are treated as text.
Action: upload
Upload a local markdown file to Feishu as a new sub-page, applying the same light-touch optimization rules as the optimize action before publishing.
Format: /feishu upload MD_PATH PARENT_URL
MD_PATH — path to the local .md file (relative to CWD or absolute)
PARENT_URL — Feishu wiki URL; the new page is created as its direct child
Core principle: The local file is the authority. Apply formatting improvements from the optimization guide, but do NOT rewrite the author's content, tone, or intent.
Workflow
Follow these 5 tasks in order:
Task 1: Read the Local Markdown File
Resolve the path:
- If
MD_PATH starts with /, it is absolute — use as-is
- Otherwise, resolve relative to the current working directory
# Resolve relative path if needed
realpath MD_PATH
Read the file content. This is the document to upload.
Analyze carefully:
- Document title (first H1, or filename if no H1)
- Overall topic and purpose
- Author's writing style and tone
- Existing heading structure and hierarchy
- Content organization and flow
- Use of formatting (bold, lists, code blocks, tables, LaTeX, etc.)
- Metadata blocks (author, venue, date, etc.)
- Technical payload that must survive: numbers, formulas, systems, complexity, deployment facts, experiment settings, citations, caveats, mechanism details
Record your observations — you will need them in Task 4 to preserve the original character.
Task 2: Format Analysis
Read [references/optimization-guide.md](/references/optimization-guide.md) for the detailed comparison framework and known format conventions.
Reference Discipline:
- The optimization guide is a style reference, not a license to restyle the document wholesale
- Preserve the source document's macro-structure unless there is a clear formatting defect
- Do not renumber or deepen the heading hierarchy just to match the reference pattern if the source already has a stable hierarchy
- If an opening block, metadata block, or summary layout already works, prefer light cleanup over redesign
- Prefer blockquote-style callouts that round-trip correctly in exported markdown
Check the document against these specific format conventions:
| Convention |
Expected Pattern |
Source Status |
| Opening callout |
[!callout] with description + paper/repo links |
Present? Missing? |
| Numbered headings |
## 1 标题 / ### 1.1 子标题 / #### 1.1.1 三级子标题 |
Correct numbering? Duplicates? |
| Heading groups |
Continuous numbering across whole doc (no resets) |
Multiple ## 1 resets? |
| Level conflicts |
Group/chapter titles at correct level vs. sub-items |
Any group title at same level as children? |
| Callouts/quotes |
|> / [!callout] / > 📌 freely throughout (5–15 per long doc) |
Enough callouts? TL;DR blocks styled? |
| Code block tags |
Language tag on every code block |
Any bare ```? |
| Bold key terms |
First mention of important technical terms bolded |
Applied? |
| Inline emphasis |
{red:...} / {red:**...**} for key points (10–20× in a long doc); {green:...} for first-mention key terms (5–10×) |
Enough red text? |
| LaTeX equations |
$inline$ and $$display$$ |
Correct syntax? |
| Formula placement |
Formulas in normal paragraphs, not inside blockquotes/callouts |
Any $...$ inside >? |
Hard Constraints:
- Do not assume numbered headings are mandatory when the source already has a coherent hierarchy
- Exception — Chinese ordinal headings are always a defect:
## 一、, ## 二、, ## 三、… use Chinese characters that do NOT trigger the tool's blue-number coloring. Always convert to ## 1 Title, ## 2 Title… format. This is not optional.
- Do not force extra subsection levels simply because the reference is more granular
- All siblings at the same heading level must be consistently numbered or consistently unnumbered. A lone unnumbered heading (e.g.,
## Cheatsheet) among numbered siblings must be assigned the next sequential number.
- Treat opening layout, metadata layout, and top-of-document summary layout as high-risk areas where over-editing is likely to regress the page
- Prefer blockquote-style callouts that round-trip correctly in exported markdown
Important: Only note FORMAT differences. Do not evaluate content topics.
Task 3: Content Review (Light Touch)
Read [references/conservative-edits.md](/references/conservative-edits.md) for detailed guidelines.
Fix These:
- Factual errors: Incorrect technical information, wrong version numbers, broken links
- Incomplete descriptions: Sentences that trail off, missing explanations, TODO/placeholder text
- Obvious typos: Spelling errors, grammar mistakes that change meaning
- Broken formatting: Unclosed markdown, inconsistent list indentation
Do NOT Change:
- Author's tone: If they write casually, keep it casual
- Content focus: Respect what the author chose to emphasize
- Technical opinions: If they recommend a tool or approach, keep it
- Original structure: Only adjust structure if it clearly conflicts with format conventions
- Level of detail: If the author was brief on a topic, respect that
Task 4: Generate Optimized Version
CRITICAL: The optimized document should be 80%+ identical to the original. Changes should be subtle improvements, not rewrites.
What to change:
Opening callout — Add a [!callout] block at the top if missing
Heading restructuring — Fix numbering AND hierarchy when needed:
- Apply continuous sequential numbering at all heading levels:
## 1, ## 2… for top-level; ### 1.1, ### 1.2… for second-level; #### 1.1.1, #### 1.1.2… for third-level. Never leave any heading level unnumbered if its parent level is numbered.
- Number format: Always use
## 1 Title (number then space then title — no period after the number). The upload tool automatically colors the numeric prefix blue. Format ## 1. Title (period after number) will NOT trigger auto-blue coloring.
- Heading groups: If multiple sections each restart at "1.", "2."… choose:
- Elevate the group header: if a heading logically contains sub-items also at the same level, promote it one level up
- Continuous renumber: if no clear group header, renumber all items sequentially
- Level conflicts: if a heading that groups sub-sections is at the same level as those sub-sections, promote it one level
- Renaming allowed: you MAY revise a heading's title when it's too generic — keep the core topic, just improve precision
- Reordering allowed: you MAY reorder sections when the logical flow clearly improves (note each reorder in the summary)
Callouts and quote containers — use freely throughout the document
- TL;DR blocks → always convert to blue callout:
[!callout icon=bulb bg=2 border=2] (NOT a |> quote container)
- "一句话总结" / "一句话定位" / "核心思想" / "关键结论" → normally convert to green callout:
[!callout icon=pushpin bg=3 border=3] (NOT a |> quote container); exception: if they contain $...$, $$...$$, or multiple inline equations, use normal body text or a nearby summary subsection instead
- Add
|> quote containers for other key insights, important observations, counterintuitive findings, and critical design decisions — no upper limit
- Add
> 📌 **标题**: ... blockquotes for critical facts and must-not-miss design decisions
- A well-formatted long document should have 5–15 callouts/quote containers spread across sections
Feishu Callout Syntax Rules:
- Use
> [!callout icon=...] form, not a bare [!callout ...] line
- Keep the callout marker and its body in the same blockquote group
- If unsure whether a custom callout will round-trip correctly, use a plain
> 📌 ... blockquote instead
Formula Safety Rules:
- Do not keep formula-bearing summaries inside blockquotes, callouts, or quote containers
- If a summary sentence contains LaTeX, place it as a normal paragraph or a nearby summary subsection
- If a sentence mixes prose and several formulas, prefer a normal paragraph
- If the formula is the main payload, prefer a lead-in sentence plus a standalone display equation block
Code block language tags — Add missing language tags to bare code blocks
Formatting conventions
- Bold key technical terms on first mention
- Use
inline code for function names, variables, file paths
Inline emphasis — MANDATORY
You MUST add these — a document with no color markup is incomplete:
{red:text} / {red:**text**} — red text color, use liberally throughout the document. Every key conclusion, important value, critical fact, must-not-miss point should be red. A long technical paper needs 10–20 red instances across sections. {red:**...**} for the most critical items.
{green:text} / {green:**text**} — green background highlight for key technical concepts, system names, method names on first mention in body text (5–10 per document)
Other emphasis:
{yellow:text}, {orange:text}, {blue:text}, {purple:text} — background highlights for secondary emphasis
**bold** — key technical terms, list lead-ins, first-mention important terms
*italic* — terms being defined, foreign phrases, titles
Structural emphasis for scannability:
- Bold structural signposts: Bold ALL "在...方面" / "在...上" phrases that introduce a topic shift — e.g., "在内存优化方面" → "在内存优化方面", "在通信方面" → "在通信方面". Also bold: "从...角度", "具体来说", "值得注意的是", "核心区别在于"
- Bold enumeration lead-ins: When a paragraph lists items inline (A does X, B does Y, C does Z), bold each item name: "A does X, B does Y, C does Z"
- Green-highlight enumerated technique names: When a paragraph enumerates multiple technical techniques with Chinese glosses (e.g., "通过 selective recomputation(选择性重计算)、fine-grained activation offloading(细粒度激活卸载)和 precision-aware optimizer"), apply
{green:...} to each technique name on first mention: 通过 {green:selective recomputation}(选择性重计算)、{green:fine-grained activation offloading}(细粒度激活卸载)和 {green:precision-aware optimizer}
- Red for full conclusions: Red should mark the complete actionable finding, not just a number. Bad:
{red:199.5 GB}. Good: {red:将内存需求从 199.5 GB 降至 80 GB 以下}. Each section should have 1–2 red sentences.
Rules:
- Preserve ALL existing
{red:...}, {green:...}, **bold**, *italic* exactly
- Never mark entire paragraphs — but DO mark full key sentences/clauses that a reader must not miss
- Red emphasis is reserved for conclusions and consequences, not routine explanatory clauses
- Green emphasis is used on genuine first-mention concepts, not repeated on every prominent noun
Factual corrections — Fix identified errors from Task 3
Description completion — Flesh out incomplete sections
- Add only information that is clearly implied or factually obvious
- Do NOT fabricate details or add your own opinions
Ordered list numbering — Feishu does NOT auto-renumber ordered list items. If the source markdown uses 1. for every item (a common Markdown habit), all items render as "1." in Feishu. Always use explicit sequential numbers: 1., 2., 3., 4.…
Intelligent list conversion — Dense paragraphs that enumerate items should be broken into structured lists:
- When to convert: A paragraph listing 3+ items/features/components with descriptions, separated by 、/;/semicolons, or using "A: desc, B: desc, C: desc" structure
- Format: Bullet list with bold lead-ins:
- **ItemName**: description
- When NOT to convert: Items are very short (1–2 words) with no descriptions — keep as inline list. Also keep as paragraph if the enumeration is embedded in narrative flow.
What NOT to change:
- Author's tone and voice (colorful language is intentional)
- Existing emphasis (
{red:...}, bold)
- Section scope (don't merge or split sections)
- Technical examples and code snippets (preserve exactly)
- Author's analogies and explanations
- Length (don't pad sections)
- Author's personal insights or recommendations
Produce the complete optimized markdown. Do NOT output a diff — output the full document.
Task 4.5: Content Preservation Audit
Before proceeding to upload, check for:
- Dropped bullets or list items
- Shortened mechanism descriptions
- Removed numbers, formulas, complexity, thresholds
- Removed deployment/experiment/workload facts
- Removed citations or named systems
- Macro-structure drift: added or removed top-level sections, subsection splits, or heading renumbering not justified by a broken source
- Opening-layout drift: title-adjacent summary, author/meta block, and first visual block still feel like the source rather than a template rewrite
If any technical section is materially shorter, re-check it line by line.
Task 4.6: Emphasis Audit
Before proceeding to upload, check for:
- At least 1 red conclusion in each major section
- Green first-mention highlights where new concepts appear
- Bold structural anchors
- Yellow highlights for caveats/tradeoffs where appropriate
- Emphasis density still matches the source tone; remove highlights if the page starts to feel over-marked or noisier than the reference
- Red emphasis is reserved for conclusions and consequences, not routine explanatory clauses
- Green emphasis is used on genuine first-mention concepts, not repeated on every prominent noun
Task 4.7: Rendered-Layout Regression Check
Visually inspect the final markdown and reject it if any of these regressions appear:
- Opening callout or opening summary looks weaker than the source/reference
- Top metadata collapses into stray lines or duplicated blocks
- A clean source paragraph was turned into a noisier list, or a clean list into a denser paragraph
- Headings became more numerous or deeper without a clear readability win
- Emphasis feels materially louder than the source/reference
- Callout syntax is likely to render literally instead of as a Feishu callout
Task 5: Write to Feishu
Determine the page title:
- Use the document's first H1 heading if present
- Otherwise, derive a clean title from the filename (strip path, underscores → spaces, drop
.md)
Determine the image directory:
- If the markdown file references images with relative paths (e.g.,
), set IMAGE_DIR to the directory containing the markdown file
- If images use absolute paths or the document has no images, omit
--image-dir
Create a sibling upload file and write the optimized content to it:
UPLOAD_MD="${MD_PATH%.md}_upload.md"
cp "MD_PATH" "$UPLOAD_MD"
# Edit $UPLOAD_MD directly so it contains the final upload body.
# Important: remove the H1 title line from the body (title is passed via --title).
python <skill-directory>/scripts/feishu_tool.py write PARENT_URL \
--heading-color \
--image-dir "IMAGE_DIR" \
--title "TITLE" \
--input-file "$UPLOAD_MD"
Important notes:
- Always include
--heading-color to auto-color headings by depth
- Include
--image-dir pointing to the markdown file's parent directory when images are present
- Do NOT include the
# Title H1 line in the content body. The title is set via --title. If H1 is in the body, heading depths shift by 1 and all headings get the wrong color.
- Keep the generated
*_upload.md file — do not delete it so the upload artifact can be reviewed later
- The
--input-file approach avoids shell escaping issues and enables image upload auto-retry
The script prints the URL of the newly created page. Share this URL with the user.
Post-upload verification (optional)
python <skill-directory>/scripts/feishu_tool.py read NEW_PAGE_URL
Summary Report
After completing all tasks, provide the user with:
- URL of the new page
- Changes made — brief list of formatting improvements applied
- Confidence level — how confident you are in the changes
Action: optimize
Light-touch optimization of a Feishu wiki document: fix errors, complete descriptions, and slightly improve formatting — while preserving the original author's tone, style, and intent.
Core principle: The original document is the authority. The reference document only guides formatting structure. Never rewrite or restructure aggressively.
Output: A new wiki sub-page under the reference document containing the optimized version.
Arguments
- SOURCE_URL: The document to optimize (content source)
- DEST_URL: The well-formatted reference document (format guide only; new page created under this)
Workflow
Follow these tasks in order:
- Read Source — Fetch and understand the source document
- Read Reference — Fetch and analyze the reference document's format
- Format Analysis — Compare structures and identify format gaps
- Content Review — Identify factual errors, incomplete descriptions, minor issues
- Generate Optimized Version — Apply light-touch improvements
5.5. Content Preservation Audit — Verify no content was dropped or shortened
5.6. Emphasis Audit — Verify color/bold density is appropriate
5.7. Rendered-Layout Regression Check — Verify no visual regressions
- Write to Feishu — Create new sub-page with optimized content
Task 1: Read Source Document
python <skill-directory>/scripts/feishu_tool.py read SOURCE_URL
Save the full output. This is the document to optimize.
Analyze carefully:
- Overall topic and purpose of the document
- Author's writing style and tone (formal/informal, technical/accessible)
- Existing heading structure and hierarchy
- Content organization and flow
- Level of detail in each section
- Use of formatting (bold, lists, code blocks, etc.)
- Technical payload that must survive: numbers, formulas, systems, complexity, deployment facts, experiment settings, citations, caveats, mechanism details
Record your observations — you will need them in Task 5 to preserve the original character.
Task 2: Read Reference Document
python <skill-directory>/scripts/feishu_tool.py read DEST_URL
Save the full output. This is the format reference only — not a content source.
Analyze the FORMAT only:
- Heading hierarchy pattern (depth, naming conventions)
- Section organization template
- Formatting conventions (when bold is used, list styles, etc.)
- Content density and paragraph structure
- Use of structural elements (dividers, quotes, code blocks)
Task 3: Format Analysis
Read [references/optimization-guide.md](/references/optimization-guide.md) for the detailed comparison framework and known reference format patterns.
Reference Discipline:
- The optimization guide is a style reference, not a license to restyle the document wholesale
- Preserve the source document's macro-structure unless there is a clear formatting defect
- Do not renumber or deepen the heading hierarchy just to match the reference pattern if the source already has a stable hierarchy
- If an opening block, metadata block, or summary layout already works, prefer light cleanup over redesign
- Prefer blockquote-style callouts that round-trip correctly in exported markdown
Check the source document against these specific format conventions:
| Convention |
Expected Pattern |
Source Status |
| Opening callout |
[!callout] with description + paper/repo links |
Present? Missing? |
| Numbered headings |
## 1 标题 / ### 1.1 子标题 |
Correct numbering? Duplicates? |
| Heading groups |
No section resets — numbering is continuous across whole doc |
Multiple ## 1 resets? |
| Level conflicts |
Group/chapter titles at correct level vs. their sub-items |
Any group title at same level as children? |
| Callouts/quotes |
|> / [!callout] / > 📌 freely throughout (5–15 per long doc) |
Enough callouts? TL;DR blocks styled? |
| Code block tags |
Language tag on every code block |
Any bare ```? |
| Bold key terms |
First mention of important technical terms bolded |
Applied? |
| Inline emphasis |
{red:...} / {red:**...**} for key points (10–20× in a long doc); {green:...} for first-mention key terms (5–10×) |
Enough red text? |
| LaTeX equations |
$inline$ and $$display$$ |
Correct syntax? |
| Formula placement |
Formulas in normal paragraphs, not inside blockquotes/callouts |
Any $...$ inside >? |
Hard Constraints:
- Do not assume numbered headings are mandatory when the source already has a coherent hierarchy
- Exception — Chinese ordinal headings are always a defect:
## 一、, ## 二、, ## 三、… use Chinese characters that do NOT trigger the tool's blue-number coloring. Always convert to ## 1 Title, ## 2 Title… format. This is not optional.
- Do not force extra subsection levels simply because the reference is more granular
- All siblings at the same heading level must be consistently numbered or consistently unnumbered. A lone unnumbered heading (e.g.,
## Cheatsheet) among numbered siblings must be assigned the next sequential number.
- Treat opening layout, metadata layout, and top-of-document summary layout as high-risk areas where over-editing is likely to regress the page
- Prefer blockquote-style callouts that round-trip correctly in exported markdown
Important: Only note FORMAT differences. Do not compare content topics.
Task 4: Content Review (Light Touch)
Review the source document for issues that should be fixed regardless of format:
Fix These:
- Factual errors: Incorrect technical information, wrong version numbers, broken links
- Incomplete descriptions: Sentences that trail off, missing explanations, TODO/placeholder text
- Obvious typos: Spelling errors, grammar mistakes that change meaning
- Broken formatting: Unclosed markdown, inconsistent list indentation
Do NOT Change:
- Author's tone: If they write casually, keep it casual
- Content focus: If they emphasize certain topics, respect that emphasis
- Technical opinions: If they recommend a tool or approach, keep it
- Original structure: Only adjust structure if it clearly conflicts with the reference format
- Level of detail: If the author was brief on a topic, they may have had a reason
Read [references/conservative-edits.md](/references/conservative-edits.md) for detailed guidelines on what changes are appropriate.
Task 5: Generate Optimized Version
CRITICAL: Read this section carefully before writing.
The 80/20 Rule
The optimized document should be 80%+ identical to the original. Changes should be subtle improvements, not rewrites.
What to change:
Opening callout — Add a [!callout] block at the top if missing
Heading restructuring — Fix numbering AND hierarchy when needed:
- Apply continuous sequential numbering at all heading levels:
## 1, ## 2… for top-level; ### 1.1, ### 1.2… for second-level; #### 1.1.1, #### 1.1.2… for third-level. Never leave any heading level unnumbered if its parent level is numbered.
- Number format: Always use
## 1 Title (number then space then title — no period after the number). The upload tool automatically colors the numeric prefix blue. Format ## 1. Title (period after number) will NOT trigger auto-blue coloring.
- Heading groups: If multiple independent sections each restart at "1.", "2."…, choose a fix:
- Elevate the group header: if a heading like
## 深度推导:… logically contains sub-items also at ##, promote it to # and demote sub-items to ##
- Continuous renumber: if no clear group header exists, renumber all items sequentially (1, 2, 3, 4…)
- Level conflicts: if a heading that groups several sub-sections is at the same
## level as those sub-sections, promote it one level up (## → #, ### → ##, etc.)
- Renaming allowed: you MAY revise a heading's title when it's too generic or doesn't capture the actual scope — keep the core topic, just improve precision
- Reordering allowed: you MAY reorder sections when the logical flow clearly improves (e.g., prerequisite concepts before dependent ones) — note each reorder in the summary report
Callouts and quote containers — use freely throughout the document
- TL;DR blocks → always convert to blue callout:
[!callout icon=bulb bg=2 border=2] (NOT a |> quote container)
- "一句话总结" / "一句话定位" / "核心思想" / "关键结论" → normally convert to green callout:
[!callout icon=pushpin bg=3 border=3] (NOT a |> quote container); exception: if they contain $...$, $$...$$, or multiple inline equations, use normal body text or a nearby summary subsection instead
- Add
|> quote containers for other key insights, important observations, counterintuitive findings, and critical design decisions — no upper limit
- Add
> 📌 **标题**: ... blockquotes for critical facts and must-not-miss design decisions
- A well-formatted long document should have 5–15 callouts/quote containers spread across sections
Feishu Callout Syntax Rules:
- Use
> [!callout icon=...] form, not a bare [!callout ...] line
- Keep the callout marker and its body in the same blockquote group
- If unsure whether a custom callout will round-trip correctly, use a plain
> 📌 ... blockquote instead
Formula Safety Rules:
- Do not keep formula-bearing summaries inside blockquotes, callouts, or quote containers
- If a summary sentence contains LaTeX, place it as a normal paragraph or a nearby summary subsection
- If a sentence mixes prose and several formulas, prefer a normal paragraph
- If the formula is the main payload, prefer a lead-in sentence plus a standalone display equation block
Code block language tags — Add missing language tags to bare code blocks
Formatting conventions — Apply reference patterns
- Bold key technical terms on first mention
- Use
inline code for function names, variables, file paths
Inline emphasis — MANDATORY
- Preserve ALL existing
{red:...}, {green:...}, **bold**, *italic* from the source exactly
{red:text} / {red:**text**} — red text color, use liberally throughout (10–20× for a long technical paper). Mark key conclusions, important values, critical facts in every section.
{green:text} / {green:**text**} — green background highlight for key technical concepts/system names on first mention (5–10×)
**bold** — key technical terms, lead-in labels in lists
*italic* — terms being defined, foreign phrases, titles
Structural emphasis for scannability:
- Bold structural signposts: Bold ALL "在...方面" / "在...上" phrases that introduce a topic shift — e.g., "在内存优化方面" → "在内存优化方面", "在通信方面" → "在通信方面". Also bold: "从...角度", "具体来说", "值得注意的是", "核心区别在于"
- Bold enumeration lead-ins: When a paragraph lists items inline, bold each item name
- Green-highlight enumerated technique names: When a paragraph enumerates multiple technical techniques with Chinese glosses (e.g., "通过 A(中文A)、B(中文B)和 C"), apply
{green:...} to each technique name on first mention
- Red for full conclusions: Mark the complete finding, not just a number. Each section should have 1–2 red sentences.
Rules:
- Never mark entire paragraphs — but DO mark full key sentences/clauses that a reader must not miss
- Red emphasis is reserved for conclusions and consequences, not routine explanatory clauses
- Green emphasis is used on genuine first-mention concepts, not repeated on every prominent noun
Factual corrections — Fix identified errors from Task 4
Description completion — Flesh out incomplete sections
- Add only information that is clearly implied or factually obvious
- Do NOT fabricate details or add your own opinions
Ordered list numbering — Feishu does NOT auto-renumber ordered list items. If the source markdown uses 1. for every item (a common Markdown habit), all items render as "1." in Feishu. Always use explicit sequential numbers: 1., 2., 3., 4.…
Intelligent list conversion — Dense paragraphs that enumerate items should be broken into structured lists:
- When to convert: A paragraph listing 3+ items/features/components with descriptions, separated by 、/;/semicolons
- Format: Bullet list with bold lead-ins:
- **ItemName**: description
- When NOT to convert: Items are very short with no descriptions, or the enumeration is embedded in narrative flow
What NOT to change:
- Author's tone and voice — Colorful language (e.g., 灵魂拷问, 降维打击, 一句话总结) is intentional. Keep it.
- Existing emphasis — If the author used
{red:...} or bold on something, that was intentional; don't remove or move it
- Section scope — Don't merge or split sections; don't change what each section covers
- Technical examples and code snippets — Preserve exactly
- Author's analogies and explanations — Their way of explaining is part of the value
- Length — Don't pad sections to match reference length
- Author's personal insights or recommendations — These are the core value of the document
Generating the output:
Produce the complete optimized markdown. Do NOT output a diff — output the full document.
Task 5.5: Content Preservation Audit
Before proceeding to upload, check for:
- Dropped bullets or list items
- Shortened mechanism descriptions
- Removed numbers, formulas, complexity, thresholds
- Removed deployment/experiment/workload facts
- Removed citations or named systems
- Macro-structure drift: added or removed top-level sections, subsection splits, or heading renumbering not justified by a broken source
- Opening-layout drift: title-adjacent summary, author/meta block, and first visual block still feel like the source rather than a template rewrite
If any technical section is materially shorter, re-check it line by line.
Task 5.6: Emphasis Audit
Before proceeding to upload, check for:
- At least 1 red conclusion in each major section
- Green first-mention highlights where new concepts appear
- Bold structural anchors
- Yellow highlights for caveats/tradeoffs where appropriate
- Emphasis density still matches the source tone; remove highlights if the page starts to feel over-marked or noisier than the reference
- Red emphasis is reserved for conclusions and consequences, not routine explanatory clauses
- Green emphasis is used on genuine first-mention concepts, not repeated on every prominent noun
Task 5.7: Rendered-Layout Regression Check
Visually inspect the final markdown and reject it if any of these regressions appear:
- Opening callout or opening summary looks weaker than the source/reference
- Top metadata collapses into stray lines or duplicated blocks
- A clean source paragraph was turned into a noisier list, or a clean list into a denser paragraph
- Headings became more numerous or deeper without a clear readability win
- Emphasis feels materially louder than the source/reference
- Callout syntax is likely to render literally instead of as a Feishu callout
Task 6: Write to Feishu
Determine an appropriate title. Use the source document's original title, optionally with a suffix.
Determine the image directory:
- If the source document contains images, the images were fetched from Feishu and may need re-upload. If you saved images locally during read, set
IMAGE_DIR to their directory.
- If no images are present, omit
--image-dir.
Write the optimized content to a temp file, then upload:
# Step 1: Write optimized content to a temp file using the Write tool
# (write the full optimized markdown — NO H1 line — to this path)
UPLOAD_TMP=$(mktemp /tmp/feishu_upload_XXXXXX.md)
# Step 2: Upload from file (auto-retries failed image uploads)
python <skill-directory>/scripts/feishu_tool.py write DEST_URL \
--heading-color \
--image-dir "IMAGE_DIR" \
--title "TITLE" \
--input-file "$UPLOAD_TMP"
# Step 3: Clean up temp file
rm -f "$UPLOAD_TMP"
Important notes for writing:
- Always include
--heading-color to auto-color headings by depth (required for visual formatting)
- Include
--image-dir when the document contains ima
…(truncated)
1---2name: feishu3description: Feishu (Lark) wiki tools: read pages as markdown, write markdown to new pages, optimize document formatting, upload local markdown files, copy/sync/export wiki pages. Use this skill when the user wants to interact with Feishu wiki — read, write, copy, sync, export, optimize/polish wiki pages, or upload a local .md file to Feishu. Triggers on: feishu, lark, 飞书, wiki page, read feishu, write feishu, optimize feishu, copy feishu, sync feishu, export feishu, upload feishu, upload md to feishu, upload markdown.4---56# Feishu Wiki Tools78Read, write, optimize, upload local markdown, copy, sync, and export Feishu wiki pages.910## Skill Files Location1112This skill's supporting files are located relative to this SKILL.md:1314- `scripts/feishu_tool.py` — Self-contained Python script for read/write/info operations (needs only `.env`)15- `references/optimization-guide.md` — Format comparison framework and known reference patterns16- `references/conservative-edits.md` — Guidelines for light-touch editing1718## Prerequisites1920- `.env` file with credentials (checked in order):21 1. `.env` in the current directory22 2. `~/.config/feishu_tools/.env`23 ```24 FEISHU_APP_ID=your_app_id25 FEISHU_APP_SECRET=your_app_secret26 ```27- Python packages: `requests`, `python-dotenv`2829## Data Locations3031- **Token cache**: `~/.config/feishu_tools/token_cache.json`32- **Sync state**: `~/log/feishu_tools/sync_logs/state/`33- **Sync logs**: `~/log/feishu_tools/sync_logs/` (one log per sync run)3435Install dependencies on first run:36```bash37pip install requests python-dotenv 2>/dev/null38```3940## Arguments4142$ARGUMENTS should be: `ACTION [ARGS...]`4344Determine the action from the user's intent:4546| User intent | Action |47|-------------|--------|48| Read/view/fetch a page | `read SOURCE_URL` |49| Write/create/publish a page | `write PARENT_URL` |50| Compare two pages | `diff LEFT_URL RIGHT_URL` |51| Show page metadata | `info SOURCE_URL` |52| Optimize/polish a page | `optimize SOURCE_URL DEST_URL` |53| Upload a local markdown file | `upload MD_PATH PARENT_URL` |54| Copy a page | `copy SOURCE_URL TARGET_URL` |55| Sync pages | `sync SOURCE_URL TARGET_URL` |56| Export to local files | `export SOURCE_URL` |5758**`upload` command**: `/feishu upload [md_path] [parent_url]`59- `md_path` may be relative (resolved from current working directory) or absolute60- `parent_url` is the Feishu wiki URL under which the new page will be created as a sub-page6162---6364## Action: read6566Read a Feishu wiki page and display its content as markdown.6768```bash69python <skill-directory>/scripts/feishu_tool.py read SOURCE_URL70```7172Options:73- `--no-title` — Omit the H1 title from output7475The script outputs clean markdown to stdout (logs go to stderr). Display the content to the user. If they ask follow-up questions, answer based on the retrieved text.7677### Notes78- On first run, it may prompt for OAuth authorization — follow the printed URL79- Token is cached in `~/.config/feishu_tools/token_cache.json` for subsequent runs80- Supports docx-type wiki pages only8182---8384## Action: diff8586Read two Feishu wiki pages as markdown and print a unified diff.8788```bash89python <skill-directory>/scripts/feishu_tool.py diff LEFT_URL RIGHT_URL90```9192Options:93- `--no-title` — omit the H1 title before diffing94- `--context N` — control unified diff context size (default: 3)95- `--normalize` — normalize markdown before diffing to reduce noisy differences9697Recommended use:98- Compare a newly created page against a reference page before modifying the tool or skill99- Use `--normalize` when you want to focus on substantive markdown structure differences rather than trivial separator normalization (e.g. Unicode dashes in table separator rows)100101---102103## Action: info104105Show page metadata.106107```bash108python <skill-directory>/scripts/feishu_tool.py info SOURCE_URL109```110111Prints: title, node token, obj token, obj type, space ID, has_child.112113---114115## Action: write116117Create a new Feishu wiki page from markdown content.1181191. Prepare the markdown content from the conversation or a file.1202. Write the optimized content to a temp file, then upload:121 ```bash122 # Step 1: Write content to a temp file123 UPLOAD_TMP=$(mktemp /tmp/feishu_upload_XXXXXX.md)124 cat > "$UPLOAD_TMP" << 'FEISHU_CONTENT_END'125 ## Section 1126127 Content here...128 FEISHU_CONTENT_END129130 # Step 2: Upload from file131 python <skill-directory>/scripts/feishu_tool.py write PARENT_URL \132 --title "Page Title" \133 --input-file "$UPLOAD_TMP"134135 # Step 3: Clean up136 rm -f "$UPLOAD_TMP"137 ```1383. The script prints the new page URL to stdout. **Share this URL** with the user.139140### Options141- `--heading-color` — Auto-color heading backgrounds by relative depth: outermost → **red/pink**, then orange, yellow, green, blue, purple. Explicit `{bg=N}` on a heading always wins.142- `--input-file FILE` / `-f FILE` — Read markdown from `FILE` instead of stdin. Preferred over heredoc for large documents (avoids shell escaping issues).143144### Inline formatting145| Syntax | Result |146|--------|--------|147| `**text**` | Bold |148| `*text*` | Italic |149| `` `code` `` | Inline code |150| `~~text~~` | Strikethrough |151| `[label](url)` | Link |152| `{red:text}` | 🔴 **Red text color** — use liberally for key points (10–20× per document) |153| `{red:**text**}` | 🔴 **Red bold text** — highest emphasis for critical conclusions |154| `{green:text}` | 🟢 Green background highlight |155| `{green:**text**}` | 🟢 Green highlight + bold — key concept first mention |156| `{yellow:text}` | 🟡 Yellow background highlight |157| `{orange:text}` | 🟠 Orange background highlight |158| `{blue:text}` | 🔵 Blue background highlight |159| `{purple:text}` | 🟣 Purple background highlight |160161### Notes162- New page is created as a child (sub-node) of the parent.163- If `--title` is omitted, title is extracted from the first H1.164- Always use `<< 'FEISHU_CONTENT_END'` (quoted delimiter) to prevent variable expansion in the temp file write step.165- The `--input-file` approach avoids heredoc shell escaping issues (e.g. `{red:...}` markers containing `{...}` in LaTeX).166- Supported: headings, paragraphs, bold, italic, code, strikethrough, links, bullet/ordered lists, code blocks, blockquotes, dividers, **tables** (`| col | col |` pipe format), callout blocks, quote containers (`|>` prefix), LaTeX equations, **images**.167- **Images**: Use `` in markdown. Pass `--image-dir DIR` to resolve relative image paths. Images are uploaded after block creation. If `--image-dir` is omitted, image lines are treated as text.168169---170171## Action: upload172173Upload a local markdown file to Feishu as a new sub-page, applying the same light-touch optimization rules as the `optimize` action before publishing.174175**Format**: `/feishu upload MD_PATH PARENT_URL`176177- `MD_PATH` — path to the local `.md` file (relative to CWD or absolute)178- `PARENT_URL` — Feishu wiki URL; the new page is created as its direct child179180**Core principle**: The local file is the authority. Apply formatting improvements from the optimization guide, but do NOT rewrite the author's content, tone, or intent.181182### Workflow183184Follow these 5 tasks in order:185186#### Task 1: Read the Local Markdown File187188Resolve the path:189- If `MD_PATH` starts with `/`, it is absolute — use as-is190- Otherwise, resolve relative to the current working directory191192```bash193# Resolve relative path if needed194realpath MD_PATH195```196197Read the file content. This is the document to upload.198199**Analyze carefully:**200- Document title (first H1, or filename if no H1)201- Overall topic and purpose202- Author's writing style and tone203- Existing heading structure and hierarchy204- Content organization and flow205- Use of formatting (bold, lists, code blocks, tables, LaTeX, etc.)206- Metadata blocks (author, venue, date, etc.)207- **Technical payload that must survive**: numbers, formulas, systems, complexity, deployment facts, experiment settings, citations, caveats, mechanism details208209**Record your observations** — you will need them in Task 4 to preserve the original character.210211#### Task 2: Format Analysis212213Read [`references/optimization-guide.md`](<skill-directory>/references/optimization-guide.md) for the detailed comparison framework and known format conventions.214215**Reference Discipline:**216- The optimization guide is a style reference, not a license to restyle the document wholesale217- Preserve the source document's macro-structure unless there is a clear formatting defect218- Do not renumber or deepen the heading hierarchy just to match the reference pattern if the source already has a stable hierarchy219- If an opening block, metadata block, or summary layout already works, prefer light cleanup over redesign220- Prefer blockquote-style callouts that round-trip correctly in exported markdown221222Check the document against these specific format conventions:223224| Convention | Expected Pattern | Source Status |225|------------|-----------------|---------------|226| Opening callout | `[!callout]` with description + paper/repo links | Present? Missing? |227| Numbered headings | `## 1 标题` / `### 1.1 子标题` / `#### 1.1.1 三级子标题` | Correct numbering? Duplicates? |228| Heading groups | Continuous numbering across whole doc (no resets) | Multiple `## 1` resets? |229| Level conflicts | Group/chapter titles at correct level vs. sub-items | Any group title at same level as children? |230| Callouts/quotes | `\|>` / `[!callout]` / `> 📌` freely throughout (5–15 per long doc) | Enough callouts? TL;DR blocks styled? |231| Code block tags | Language tag on every code block | Any bare ` ``` `? |232| Bold key terms | First mention of important technical terms bolded | Applied? |233| Inline emphasis | `{red:...}` / `{red:**...**}` for key points (10–20× in a long doc); `{green:...}` for first-mention key terms (5–10×) | Enough red text? |234| LaTeX equations | `$inline$` and `$$display$$` | Correct syntax? |235| Formula placement | Formulas in normal paragraphs, not inside blockquotes/callouts | Any `$...$` inside `>`? |236237**Hard Constraints:**238- Do **not** assume numbered headings are mandatory when the source already has a coherent hierarchy239- **Exception — Chinese ordinal headings are always a defect**: `## 一、`, `## 二、`, `## 三、`… use Chinese characters that do NOT trigger the tool's blue-number coloring. Always convert to `## 1 Title`, `## 2 Title`… format. This is not optional.240- Do **not** force extra subsection levels simply because the reference is more granular241- **All siblings at the same heading level must be consistently numbered or consistently unnumbered.** A lone unnumbered heading (e.g., `## Cheatsheet`) among numbered siblings must be assigned the next sequential number.242- Treat opening layout, metadata layout, and top-of-document summary layout as high-risk areas where over-editing is likely to regress the page243- Prefer blockquote-style callouts that round-trip correctly in exported markdown244245**Important**: Only note FORMAT differences. Do not evaluate content topics.246247#### Task 3: Content Review (Light Touch)248249Read [`references/conservative-edits.md`](<skill-directory>/references/conservative-edits.md) for detailed guidelines.250251**Fix These:**252- **Factual errors**: Incorrect technical information, wrong version numbers, broken links253- **Incomplete descriptions**: Sentences that trail off, missing explanations, TODO/placeholder text254- **Obvious typos**: Spelling errors, grammar mistakes that change meaning255- **Broken formatting**: Unclosed markdown, inconsistent list indentation256257**Do NOT Change:**258- **Author's tone**: If they write casually, keep it casual259- **Content focus**: Respect what the author chose to emphasize260- **Technical opinions**: If they recommend a tool or approach, keep it261- **Original structure**: Only adjust structure if it clearly conflicts with format conventions262- **Level of detail**: If the author was brief on a topic, respect that263264#### Task 4: Generate Optimized Version265266**CRITICAL**: The optimized document should be **80%+ identical** to the original. Changes should be subtle improvements, not rewrites.267268**What to change:**2692701. **Opening callout** — Add a `[!callout]` block at the top if missing271 - Use `[!callout icon=ICON bg=2 border=2]` — choose an appropriate icon (e.g. `gift`, `bulb`, `bookmark`, `pushpin`, `rocket`, `star`)272 - Put the document's intro description AND paper/code links **all inside** the callout as child paragraphs273 - Example:274 ```275 > [!callout icon=gift bg=2 border=2]276 > 本文档...的简介文字。277 >278 > **Paper**: [Title](url)279 >280 > **Code**: [GitHub](url)281 >282 ```283 - If the source already has an intro `|>` quote container or a plain `>` blockquote that functions as the document summary (e.g., `> 一句话总结: ...`), move its text into the callout as a child paragraph and remove the original block2842852. **Heading restructuring** — Fix numbering AND hierarchy when needed:286 - Apply **continuous sequential numbering at all heading levels**: `## 1`, `## 2`… for top-level; `### 1.1`, `### 1.2`… for second-level; `#### 1.1.1`, `#### 1.1.2`… for third-level. Never leave any heading level unnumbered if its parent level is numbered.287 - **Number format**: Always use `## 1 Title` (number then space then title — **no period** after the number). The upload tool automatically colors the numeric prefix blue. Format `## 1. Title` (period after number) will NOT trigger auto-blue coloring.288 - **Heading groups**: If multiple sections each restart at "1.", "2."… choose:289 - *Elevate the group header*: if a heading logically contains sub-items also at the same level, promote it one level up290 - *Continuous renumber*: if no clear group header, renumber all items sequentially291 - **Level conflicts**: if a heading that groups sub-sections is at the same level as those sub-sections, promote it one level292 - **Renaming allowed**: you MAY revise a heading's title when it's too generic — keep the core topic, just improve precision293 - **Reordering allowed**: you MAY reorder sections when the logical flow clearly improves (note each reorder in the summary)2942953. **Callouts and quote containers — use freely throughout the document**296 - **TL;DR blocks** → always convert to **blue callout**: `[!callout icon=bulb bg=2 border=2]` (NOT a `|>` quote container)297 - **"一句话总结" / "一句话定位" / "核心思想" / "关键结论"** → normally convert to **green callout**: `[!callout icon=pushpin bg=3 border=3]` (NOT a `|>` quote container); **exception**: if they contain `$...$`, `$$...$$`, or multiple inline equations, use normal body text or a nearby summary subsection instead298 - Add `|>` quote containers for other key insights, important observations, counterintuitive findings, and critical design decisions — no upper limit299 - Add `> 📌 **标题**: ...` blockquotes for critical facts and must-not-miss design decisions300 - A well-formatted long document should have **5–15 callouts/quote containers** spread across sections301302 **Feishu Callout Syntax Rules:**303 - Use `> [!callout icon=...]` form, not a bare `[!callout ...]` line304 - Keep the callout marker and its body in the same blockquote group305 - If unsure whether a custom callout will round-trip correctly, use a plain `> 📌 ...` blockquote instead306307 **Formula Safety Rules:**308 - Do **not** keep formula-bearing summaries inside blockquotes, callouts, or quote containers309 - If a summary sentence contains LaTeX, place it as a normal paragraph or a nearby summary subsection310 - If a sentence mixes prose and several formulas, prefer a normal paragraph311 - If the formula is the main payload, prefer a lead-in sentence plus a standalone display equation block3123134. **Code block language tags** — Add missing language tags to bare code blocks3143155. **Formatting conventions**316 - Bold key technical terms on first mention317 - Use `inline code` for function names, variables, file paths3183196. **Inline emphasis — MANDATORY**320321 **You MUST add these — a document with no color markup is incomplete:**322 - `{red:text}` / `{red:**text**}` — **red text color**, use **liberally throughout** the document. Every key conclusion, important value, critical fact, must-not-miss point should be red. A long technical paper needs 10–20 red instances across sections. `{red:**...**}` for the most critical items.323 - `{green:text}` / `{green:**text**}` — **green background highlight** for key technical concepts, system names, method names on **first mention** in body text (5–10 per document)324325 **Other emphasis:**326 - `{yellow:text}`, `{orange:text}`, `{blue:text}`, `{purple:text}` — background highlights for secondary emphasis327 - `**bold**` — key technical terms, list lead-ins, first-mention important terms328 - `*italic*` — terms being defined, foreign phrases, titles329330 **Structural emphasis for scannability:**331 - **Bold structural signposts**: Bold ALL "在...方面" / "在...上" phrases that introduce a topic shift — e.g., "在内存优化方面" → "**在内存优化方面**", "在通信方面" → "**在通信方面**". Also bold: "**从...角度**", "**具体来说**", "**值得注意的是**", "**核心区别在于**"332 - **Bold enumeration lead-ins**: When a paragraph lists items inline (A does X, B does Y, C does Z), bold each item name: "**A** does X, **B** does Y, **C** does Z"333 - **Green-highlight enumerated technique names**: When a paragraph enumerates multiple technical techniques with Chinese glosses (e.g., "通过 selective recomputation(选择性重计算)、fine-grained activation offloading(细粒度激活卸载)和 precision-aware optimizer"), apply `{green:...}` to each technique name on first mention: `通过 {green:selective recomputation}(选择性重计算)、{green:fine-grained activation offloading}(细粒度激活卸载)和 {green:precision-aware optimizer}`334 - **Red for full conclusions**: Red should mark the complete actionable finding, not just a number. Bad: `{red:199.5 GB}`. Good: `{red:将内存需求从 199.5 GB 降至 80 GB 以下}`. Each section should have 1–2 red sentences.335336 Rules:337 - Preserve ALL existing `{red:...}`, `{green:...}`, `**bold**`, `*italic*` exactly338 - Never mark entire paragraphs — but DO mark full key sentences/clauses that a reader must not miss339 - Red emphasis is reserved for conclusions and consequences, not routine explanatory clauses340 - Green emphasis is used on genuine first-mention concepts, not repeated on every prominent noun3413427. **Factual corrections** — Fix identified errors from Task 33433448. **Description completion** — Flesh out incomplete sections345 - Add only information that is clearly implied or factually obvious346 - Do NOT fabricate details or add your own opinions3473489. **Ordered list numbering** — Feishu does NOT auto-renumber ordered list items. If the source markdown uses `1.` for every item (a common Markdown habit), all items render as "1." in Feishu. Always use explicit sequential numbers: `1.`, `2.`, `3.`, `4.`…34935010. **Intelligent list conversion** — Dense paragraphs that enumerate items should be broken into structured lists:351 - **When to convert**: A paragraph listing 3+ items/features/components with descriptions, separated by 、/;/semicolons, or using "A: desc, B: desc, C: desc" structure352 - **Format**: Bullet list with bold lead-ins: `- **ItemName**: description`353 - **When NOT to convert**: Items are very short (1–2 words) with no descriptions — keep as inline list. Also keep as paragraph if the enumeration is embedded in narrative flow.354355**What NOT to change:**356- Author's tone and voice (colorful language is intentional)357- Existing emphasis (`{red:...}`, bold)358- Section scope (don't merge or split sections)359- Technical examples and code snippets (preserve exactly)360- Author's analogies and explanations361- Length (don't pad sections)362- Author's personal insights or recommendations363364Produce the **complete optimized markdown**. Do NOT output a diff — output the full document.365366#### Task 4.5: Content Preservation Audit367368Before proceeding to upload, check for:369- Dropped bullets or list items370- Shortened mechanism descriptions371- Removed numbers, formulas, complexity, thresholds372- Removed deployment/experiment/workload facts373- Removed citations or named systems374- Macro-structure drift: added or removed top-level sections, subsection splits, or heading renumbering not justified by a broken source375- Opening-layout drift: title-adjacent summary, author/meta block, and first visual block still feel like the source rather than a template rewrite376377If any technical section is materially shorter, re-check it line by line.378379#### Task 4.6: Emphasis Audit380381Before proceeding to upload, check for:382- At least 1 red conclusion in each major section383- Green first-mention highlights where new concepts appear384- Bold structural anchors385- Yellow highlights for caveats/tradeoffs where appropriate386- Emphasis density still matches the source tone; remove highlights if the page starts to feel over-marked or noisier than the reference387- Red emphasis is reserved for conclusions and consequences, not routine explanatory clauses388- Green emphasis is used on genuine first-mention concepts, not repeated on every prominent noun389390#### Task 4.7: Rendered-Layout Regression Check391392Visually inspect the final markdown and reject it if any of these regressions appear:393- Opening callout or opening summary looks weaker than the source/reference394- Top metadata collapses into stray lines or duplicated blocks395- A clean source paragraph was turned into a noisier list, or a clean list into a denser paragraph396- Headings became more numerous or deeper without a clear readability win397- Emphasis feels materially louder than the source/reference398- Callout syntax is likely to render literally instead of as a Feishu callout399400#### Task 5: Write to Feishu401402Determine the page title:403- Use the document's first H1 heading if present404- Otherwise, derive a clean title from the filename (strip path, underscores → spaces, drop `.md`)405406Determine the image directory:407- If the markdown file references images with relative paths (e.g., ``), set `IMAGE_DIR` to the directory containing the markdown file408- If images use absolute paths or the document has no images, omit `--image-dir`409410Create a sibling upload file and write the optimized content to it:411412```bash413UPLOAD_MD="${MD_PATH%.md}_upload.md"414cp "MD_PATH" "$UPLOAD_MD"415# Edit $UPLOAD_MD directly so it contains the final upload body.416# Important: remove the H1 title line from the body (title is passed via --title).417418python <skill-directory>/scripts/feishu_tool.py write PARENT_URL \419 --heading-color \420 --image-dir "IMAGE_DIR" \421 --title "TITLE" \422 --input-file "$UPLOAD_MD"423```424425**Important notes:**426- Always include `--heading-color` to auto-color headings by depth427- Include `--image-dir` pointing to the markdown file's parent directory when images are present428- **Do NOT include the `# Title` H1 line in the content body.** The title is set via `--title`. If H1 is in the body, heading depths shift by 1 and all headings get the wrong color.429- **Keep the generated `*_upload.md` file — do not delete it** so the upload artifact can be reviewed later430- The `--input-file` approach avoids shell escaping issues and enables image upload auto-retry431432The script prints the URL of the newly created page. **Share this URL with the user.**433434#### Post-upload verification (optional)435436```bash437python <skill-directory>/scripts/feishu_tool.py read NEW_PAGE_URL438```439440### Summary Report441442After completing all tasks, provide the user with:4434441. **URL** of the new page4452. **Changes made** — brief list of formatting improvements applied4463. **Confidence level** — how confident you are in the changes447448---449450## Action: optimize451452Light-touch optimization of a Feishu wiki document: fix errors, complete descriptions, and slightly improve formatting — while preserving the original author's tone, style, and intent.453454**Core principle**: The original document is the authority. The reference document only guides formatting structure. Never rewrite or restructure aggressively.455456**Output**: A new wiki sub-page under the reference document containing the optimized version.457458### Arguments459460- **SOURCE_URL**: The document to optimize (content source)461- **DEST_URL**: The well-formatted reference document (format guide only; new page created under this)462463### Workflow464465Follow these tasks in order:4664671. **Read Source** — Fetch and understand the source document4682. **Read Reference** — Fetch and analyze the reference document's format4693. **Format Analysis** — Compare structures and identify format gaps4704. **Content Review** — Identify factual errors, incomplete descriptions, minor issues4715. **Generate Optimized Version** — Apply light-touch improvements4725.5. **Content Preservation Audit** — Verify no content was dropped or shortened4735.6. **Emphasis Audit** — Verify color/bold density is appropriate4745.7. **Rendered-Layout Regression Check** — Verify no visual regressions4756. **Write to Feishu** — Create new sub-page with optimized content476477### Task 1: Read Source Document478479```bash480python <skill-directory>/scripts/feishu_tool.py read SOURCE_URL481```482483Save the full output. This is the document to optimize.484485**Analyze carefully:**486- Overall topic and purpose of the document487- Author's writing style and tone (formal/informal, technical/accessible)488- Existing heading structure and hierarchy489- Content organization and flow490- Level of detail in each section491- Use of formatting (bold, lists, code blocks, etc.)492- **Technical payload that must survive**: numbers, formulas, systems, complexity, deployment facts, experiment settings, citations, caveats, mechanism details493494**Record your observations** — you will need them in Task 5 to preserve the original character.495496### Task 2: Read Reference Document497498```bash499python <skill-directory>/scripts/feishu_tool.py read DEST_URL500```501502Save the full output. This is the format reference only — not a content source.503504**Analyze the FORMAT only:**505- Heading hierarchy pattern (depth, naming conventions)506- Section organization template507- Formatting conventions (when bold is used, list styles, etc.)508- Content density and paragraph structure509- Use of structural elements (dividers, quotes, code blocks)510511### Task 3: Format Analysis512513Read [`references/optimization-guide.md`](<skill-directory>/references/optimization-guide.md) for the detailed comparison framework and known reference format patterns.514515**Reference Discipline:**516- The optimization guide is a style reference, not a license to restyle the document wholesale517- Preserve the source document's macro-structure unless there is a clear formatting defect518- Do not renumber or deepen the heading hierarchy just to match the reference pattern if the source already has a stable hierarchy519- If an opening block, metadata block, or summary layout already works, prefer light cleanup over redesign520- Prefer blockquote-style callouts that round-trip correctly in exported markdown521522Check the source document against these specific format conventions:523524| Convention | Expected Pattern | Source Status |525|------------|-----------------|---------------|526| Opening callout | `[!callout]` with description + paper/repo links | Present? Missing? |527| Numbered headings | `## 1 标题` / `### 1.1 子标题` | Correct numbering? Duplicates? |528| Heading groups | No section resets — numbering is continuous across whole doc | Multiple `## 1` resets? |529| Level conflicts | Group/chapter titles at correct level vs. their sub-items | Any group title at same level as children? |530| Callouts/quotes | `\|>` / `[!callout]` / `> 📌` freely throughout (5–15 per long doc) | Enough callouts? TL;DR blocks styled? |531| Code block tags | Language tag on every code block | Any bare ` ``` `? |532| Bold key terms | First mention of important technical terms bolded | Applied? |533| Inline emphasis | `{red:...}` / `{red:**...**}` for key points (10–20× in a long doc); `{green:...}` for first-mention key terms (5–10×) | Enough red text? |534| LaTeX equations | `$inline$` and `$$display$$` | Correct syntax? |535| Formula placement | Formulas in normal paragraphs, not inside blockquotes/callouts | Any `$...$` inside `>`? |536537**Hard Constraints:**538- Do **not** assume numbered headings are mandatory when the source already has a coherent hierarchy539- **Exception — Chinese ordinal headings are always a defect**: `## 一、`, `## 二、`, `## 三、`… use Chinese characters that do NOT trigger the tool's blue-number coloring. Always convert to `## 1 Title`, `## 2 Title`… format. This is not optional.540- Do **not** force extra subsection levels simply because the reference is more granular541- **All siblings at the same heading level must be consistently numbered or consistently unnumbered.** A lone unnumbered heading (e.g., `## Cheatsheet`) among numbered siblings must be assigned the next sequential number.542- Treat opening layout, metadata layout, and top-of-document summary layout as high-risk areas where over-editing is likely to regress the page543- Prefer blockquote-style callouts that round-trip correctly in exported markdown544545**Important**: Only note FORMAT differences. Do not compare content topics.546547### Task 4: Content Review (Light Touch)548549Review the source document for issues that should be fixed regardless of format:550551**Fix These:**552- **Factual errors**: Incorrect technical information, wrong version numbers, broken links553- **Incomplete descriptions**: Sentences that trail off, missing explanations, TODO/placeholder text554- **Obvious typos**: Spelling errors, grammar mistakes that change meaning555- **Broken formatting**: Unclosed markdown, inconsistent list indentation556557**Do NOT Change:**558- **Author's tone**: If they write casually, keep it casual559- **Content focus**: If they emphasize certain topics, respect that emphasis560- **Technical opinions**: If they recommend a tool or approach, keep it561- **Original structure**: Only adjust structure if it clearly conflicts with the reference format562- **Level of detail**: If the author was brief on a topic, they may have had a reason563564Read [`references/conservative-edits.md`](<skill-directory>/references/conservative-edits.md) for detailed guidelines on what changes are appropriate.565566### Task 5: Generate Optimized Version567568**CRITICAL**: Read this section carefully before writing.569570#### The 80/20 Rule571572The optimized document should be **80%+ identical** to the original. Changes should be subtle improvements, not rewrites.573574#### What to change:5755761. **Opening callout** — Add a `[!callout]` block at the top if missing577 - Use `[!callout icon=ICON bg=2 border=2]` — choose an appropriate icon freely (e.g. `gift`, `bulb`, `bookmark`, `pushpin`, `rocket`, `star`)578 - Put the document's intro description AND paper/code links **all inside** the callout as child paragraphs (separated by blank `>` lines)579 - Example:580 ```581 > [!callout icon=gift bg=2 border=2]582 > 本文档...的简介文字。583 >584 > **Paper**: [Title](url)585 >586 > **Code**: [GitHub](url)587 >588 ```589 - If the source already has an intro `|>` quote container or a plain `>` blockquote that functions as the document summary (e.g., `> 一句话总结: ...`), move its text into the callout as a child paragraph and remove the original block5905912. **Heading restructuring** — Fix numbering AND hierarchy when needed:592 - Apply **continuous sequential numbering at all heading levels**: `## 1`, `## 2`… for top-level; `### 1.1`, `### 1.2`… for second-level; `#### 1.1.1`, `#### 1.1.2`… for third-level. Never leave any heading level unnumbered if its parent level is numbered.593 - **Number format**: Always use `## 1 Title` (number then space then title — **no period** after the number). The upload tool automatically colors the numeric prefix blue. Format `## 1. Title` (period after number) will NOT trigger auto-blue coloring.594 - **Heading groups**: If multiple independent sections each restart at "1.", "2."…, choose a fix:595 - *Elevate the group header*: if a heading like `## 深度推导:…` logically contains sub-items also at `##`, promote it to `#` and demote sub-items to `##`596 - *Continuous renumber*: if no clear group header exists, renumber all items sequentially (1, 2, 3, 4…)597 - **Level conflicts**: if a heading that groups several sub-sections is at the same `##` level as those sub-sections, promote it one level up (`##` → `#`, `###` → `##`, etc.)598 - **Renaming allowed**: you MAY revise a heading's title when it's too generic or doesn't capture the actual scope — keep the core topic, just improve precision599 - **Reordering allowed**: you MAY reorder sections when the logical flow clearly improves (e.g., prerequisite concepts before dependent ones) — note each reorder in the summary report6006013. **Callouts and quote containers — use freely throughout the document**602 - **TL;DR blocks** → always convert to **blue callout**: `[!callout icon=bulb bg=2 border=2]` (NOT a `|>` quote container)603 - **"一句话总结" / "一句话定位" / "核心思想" / "关键结论"** → normally convert to **green callout**: `[!callout icon=pushpin bg=3 border=3]` (NOT a `|>` quote container); **exception**: if they contain `$...$`, `$$...$$`, or multiple inline equations, use normal body text or a nearby summary subsection instead604 - Add `|>` quote containers for other key insights, important observations, counterintuitive findings, and critical design decisions — no upper limit605 - Add `> 📌 **标题**: ...` blockquotes for critical facts and must-not-miss design decisions606 - A well-formatted long document should have **5–15 callouts/quote containers** spread across sections607608 **Feishu Callout Syntax Rules:**609 - Use `> [!callout icon=...]` form, not a bare `[!callout ...]` line610 - Keep the callout marker and its body in the same blockquote group611 - If unsure whether a custom callout will round-trip correctly, use a plain `> 📌 ...` blockquote instead612613 **Formula Safety Rules:**614 - Do **not** keep formula-bearing summaries inside blockquotes, callouts, or quote containers615 - If a summary sentence contains LaTeX, place it as a normal paragraph or a nearby summary subsection616 - If a sentence mixes prose and several formulas, prefer a normal paragraph617 - If the formula is the main payload, prefer a lead-in sentence plus a standalone display equation block6186194. **Code block language tags** — Add missing language tags to bare code blocks6206215. **Formatting conventions** — Apply reference patterns622 - Bold key technical terms on first mention623 - Use `inline code` for function names, variables, file paths6246256. **Inline emphasis — MANDATORY**626 - Preserve ALL existing `{red:...}`, `{green:...}`, `**bold**`, `*italic*` from the source exactly627 - `{red:text}` / `{red:**text**}` — **red text color**, use **liberally throughout** (10–20× for a long technical paper). Mark key conclusions, important values, critical facts in every section.628 - `{green:text}` / `{green:**text**}` — **green background highlight** for key technical concepts/system names on first mention (5–10×)629 - `**bold**` — key technical terms, lead-in labels in lists630 - `*italic*` — terms being defined, foreign phrases, titles631632 **Structural emphasis for scannability:**633 - **Bold structural signposts**: Bold ALL "在...方面" / "在...上" phrases that introduce a topic shift — e.g., "在内存优化方面" → "**在内存优化方面**", "在通信方面" → "**在通信方面**". Also bold: "**从...角度**", "**具体来说**", "**值得注意的是**", "**核心区别在于**"634 - **Bold enumeration lead-ins**: When a paragraph lists items inline, bold each item name635 - **Green-highlight enumerated technique names**: When a paragraph enumerates multiple technical techniques with Chinese glosses (e.g., "通过 A(中文A)、B(中文B)和 C"), apply `{green:...}` to each technique name on first mention636 - **Red for full conclusions**: Mark the complete finding, not just a number. Each section should have 1–2 red sentences.637638 Rules:639 - Never mark entire paragraphs — but DO mark full key sentences/clauses that a reader must not miss640 - Red emphasis is reserved for conclusions and consequences, not routine explanatory clauses641 - Green emphasis is used on genuine first-mention concepts, not repeated on every prominent noun6426437. **Factual corrections** — Fix identified errors from Task 46446458. **Description completion** — Flesh out incomplete sections646 - Add only information that is clearly implied or factually obvious647 - Do NOT fabricate details or add your own opinions6486499. **Ordered list numbering** — Feishu does NOT auto-renumber ordered list items. If the source markdown uses `1.` for every item (a common Markdown habit), all items render as "1." in Feishu. Always use explicit sequential numbers: `1.`, `2.`, `3.`, `4.`…65065110. **Intelligent list conversion** — Dense paragraphs that enumerate items should be broken into structured lists:652 - **When to convert**: A paragraph listing 3+ items/features/components with descriptions, separated by 、/;/semicolons653 - **Format**: Bullet list with bold lead-ins: `- **ItemName**: description`654 - **When NOT to convert**: Items are very short with no descriptions, or the enumeration is embedded in narrative flow655656#### What NOT to change:657658- **Author's tone and voice** — Colorful language (e.g., 灵魂拷问, 降维打击, 一句话总结) is intentional. Keep it.659- **Existing emphasis** — If the author used `{red:...}` or bold on something, that was intentional; don't remove or move it660- **Section scope** — Don't merge or split sections; don't change what each section covers661- **Technical examples and code snippets** — Preserve exactly662- **Author's analogies and explanations** — Their way of explaining is part of the value663- **Length** — Don't pad sections to match reference length664- **Author's personal insights or recommendations** — These are the core value of the document665666#### Generating the output:667668Produce the complete optimized markdown. Do NOT output a diff — output the full document.669670### Task 5.5: Content Preservation Audit671672Before proceeding to upload, check for:673- Dropped bullets or list items674- Shortened mechanism descriptions675- Removed numbers, formulas, complexity, thresholds676- Removed deployment/experiment/workload facts677- Removed citations or named systems678- Macro-structure drift: added or removed top-level sections, subsection splits, or heading renumbering not justified by a broken source679- Opening-layout drift: title-adjacent summary, author/meta block, and first visual block still feel like the source rather than a template rewrite680681If any technical section is materially shorter, re-check it line by line.682683### Task 5.6: Emphasis Audit684685Before proceeding to upload, check for:686- At least 1 red conclusion in each major section687- Green first-mention highlights where new concepts appear688- Bold structural anchors689- Yellow highlights for caveats/tradeoffs where appropriate690- Emphasis density still matches the source tone; remove highlights if the page starts to feel over-marked or noisier than the reference691- Red emphasis is reserved for conclusions and consequences, not routine explanatory clauses692- Green emphasis is used on genuine first-mention concepts, not repeated on every prominent noun693694### Task 5.7: Rendered-Layout Regression Check695696Visually inspect the final markdown and reject it if any of these regressions appear:697- Opening callout or opening summary looks weaker than the source/reference698- Top metadata collapses into stray lines or duplicated blocks699- A clean source paragraph was turned into a noisier list, or a clean list into a denser paragraph700- Headings became more numerous or deeper without a clear readability win701- Emphasis feels materially louder than the source/reference702- Callout syntax is likely to render literally instead of as a Feishu callout703704### Task 6: Write to Feishu705706Determine an appropriate title. Use the source document's original title, optionally with a suffix.707708Determine the image directory:709- If the source document contains images, the images were fetched from Feishu and may need re-upload. If you saved images locally during read, set `IMAGE_DIR` to their directory.710- If no images are present, omit `--image-dir`.711712Write the optimized content to a temp file, then upload:713714```bash715# Step 1: Write optimized content to a temp file using the Write tool716# (write the full optimized markdown — NO H1 line — to this path)717UPLOAD_TMP=$(mktemp /tmp/feishu_upload_XXXXXX.md)718719# Step 2: Upload from file (auto-retries failed image uploads)720python <skill-directory>/scripts/feishu_tool.py write DEST_URL \721 --heading-color \722 --image-dir "IMAGE_DIR" \723 --title "TITLE" \724 --input-file "$UPLOAD_TMP"725726# Step 3: Clean up temp file727rm -f "$UPLOAD_TMP"728```729730**Important notes for writing:**731- Always include `--heading-color` to auto-color headings by depth (required for visual formatting)732- Include `--image-dir` when the document contains ima733734…(truncated)