AGENT SKILL
book_chapter.update_from_source
Update a book's content to match changes in its source file
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-02
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- model
- opus
- description
- Update a book's content to match changes in its source file
03 SKILL.md 正文
Goal
- Given the content of a book in the form of a markdown or tex file
<TARGET>and a source file<SOURCE>, find and incorporate the changes from<SOURCE>into<TARGET>
Workflow
Read the Version Header
- The file
<SOURCE>contains a header with the last version, in terms of Git hash and timestamp, of the material used to generate the current version of<TARGET>- E.g.,
% git_hash=<GIT_HASH>, timestamp=<TIMESTAMP> % <SOURCE> - E.g.,
% git_hash=f15bc6b9, timestamp=2026-07-15 14:41:12 EDT % book_springer/lectures_source/Lesson02.1_From_Data_Science_To_Decision_Science.txt
- E.g.,
- Get the diff of
<SOURCE>since<GIT_HASH>once, up front, instead of re-diffing piecemeal per section:> git diff <GIT_HASH> -- <SOURCE>
Incorporate Changes
- Find what changed in
<SOURCE>from<GIT_HASH>to now, and modify<TARGET>to incorporate those changes - Follow the same style as
<TARGET>(e.g., read the corresponding.claude/skills/*.rules.md) <TARGET>is allowed to be a superset of<SOURCE>(e.g., a.typbook chapter routinely has headings, diagrams, or explanatory paragraphs that group or expand several flat.smdslides, pertypst.rules.md's "Structural Hierarchy"). When<SOURCE>drops a heading or a diagram that<TARGET>already built on, do not delete the corresponding<TARGET>content just because it no longer has a direct counterpart: only remove it if the diff shows the underlying fact/example was itself changed or retracted, not merely reorganized out of the slide deck- Update the header at the top of
<TARGET>to the new hash/timestamp once done:// git_hash=<NEW_GIT_HASH> timestamp=<NEW_TIMESTAMP>
Compare Entire Flow
- Make sure the flow of the
<TARGET>book chapter (in typst, latex, md format) follows the flow of the<SOURCE> - E.g., you can run
extract_toc_from_txt.pyon<SOURCE>and<TARGET>and compare> extract_toc_from_txt.py -i msml610/lectures_source/Lesson03.3-Non_classical_logics.smd > extract_toc_from_txt.py -i msml610/book/Lesson03.3-Non_classical_logics.typ - Ensure that the flow of
<TARGET>is consistent with<SOURCE>
Update Source-Line References
- A
.typ<TARGET>carries a// From: <SOURCE>:<LINE> '<slide title>'comment above each section, pointing at the exact<SOURCE>line it was generated from - Any edit to
<SOURCE>above a given slide shifts every later line number: after incorporating the changes, re-walk<TARGET>'s// From:comments top to bottom and update each<LINE>to match the slide's current position in<SOURCE>(grep<SOURCE>for the slide's*/#title to find it)
Update Rendered Images
- When
<SOURCE>'s diff changes agraphviz/mermaid/tikz/... code block (new styling, new nodes, a swapped static image for a rendered diagram, or vice versa), carry that same code change into<TARGET>'s matchingrendered_images:begin/rendered_images:endplaceholder (seetypst.rules.md's "Diagram Placeholders andwrap-content") - Never touch the numbered
.pngfilenames (<Chapter>.typ.figs/<Chapter>.<N>.png) or the figure#figure(image(...))calls by hand for content that already renders correctly:render_images.pyregenerates both the images and their numbering from the placeholders on the next render - If a section gains or loses a rendered figure, every later figure's
<N>shifts; after editing the placeholders, grep<TARGET>for\.typ\.figs/.*\.[0-9]+\.pngand renumber every#figure(image(...))call (and its matchinglabel=/caption=metadata line) sequentially from 1, in document order, so the bare#figure(...)blocks stay in sync with what the next render will produce - Carry over caption/label wording changes the same way you would prose: if
<SOURCE>'s diff renames or rewords what a diagram depicts, update the figure'scaption=/caption:to match, followingtypst.rules.md's "Figures: Required Elements" (sentence case, one plain line, no node-by-node listing)
Verification
- [ ] Confirm every change in
<SOURCE>since<GIT_HASH>is reflected in<TARGET> - [ ] Confirm
<TARGET>still follows the style of its corresponding.claude/skills/*.rules.md(typst.rules.md,latex.rules.md, ormarkdown.rules.md, depending on<TARGET>'s format) - [ ] Confirm
<TARGET>compiles- For a
.typ<TARGET>, userender_book_chapter.py -i <TARGET>when a working Docker/graphviz setup is available - As a lighter syntax-only check that doesn't need Docker (and avoids
render_book_chapter.py's Docker/graphviz image-tagging bug, and its side-effect of re-rendering other.typfiles if agen_slides.py --daemonis watching the same book directory), stub out any not-yet-rendered figure PNGs and compile directly:> typst compile --root . <TARGET> /tmp/check.pdf - After either check,
git status/git diffthe whole book directory, not just<TARGET>, to catch an unintended side effect on a sibling chapter
- For a
- [ ] Confirm every
// From: <SOURCE>:<LINE>comment in<TARGET>points at the correct, current line in<SOURCE> - [ ] Confirm every figure's numbered
.pngfilename is sequential in document order with no gaps or duplicates
04 同仓库更多 Skills
tutorial_in_60_mins.propagate_docker_changes
Sync tutorial and class-project Docker files to match project_template
★ 0
tutorial_in_60_mins.merge_markdown
Merge the content of a markdown file into a Jupyter notebook
★ 0
tutorial_in_60_mins.format
Format a directory to follow the "Learn X in 60 Minutes" tutorial conventions
★ 0
tutorial_in_60_mins.create
Create a tutorial directory for the Learn X in 60 Minutes conventions
★ 0
todo.reorg_in_progress
Reorganize ai_task_queue.md so in-progress tasks, not-started tasks, and mislabeled topic headers sit under the right H1 stage
★ 0
todo.reorg_headers
Reorganize ai_task_queue.md .md so every H2 topic matches ALL TOPICS and every H3 task sits under the right topic, keeping its H1 stage
★ 0