Skip to content

Commit 2a0be8a

Browse files
apartsinclaude
andcommitted
Standardize callouts, fix epigraphs, add Mermaid diagrams, revert broken SVG conversions
Major changes across 410+ files: - Convert 5 Author's Perspective callouts to standard Note callouts, remove first-person prose - Move 10 epigraphs from outside to inside <main> tag (part indexes + appendices index) - Add 18 new Mermaid diagrams for prose-heavy sections (Ch 11, 12, 20, 21, 22, 25, 26, 29, 30, 31, 32, 33) - Convert 10 inline SVGs to proper Mermaid PNGs (Fig 1.3.6, 2.2.5, 3.1.6, 3.2.4, 4.1.7, 5.2.3, 10.1.2, 10.1.5, 10.2.2, 10.2.4) - Revert 183 broken SVG-to-Mermaid conversions (agent generated caption-only stubs) - Delete 183 broken .mmd/.png pairs, restore original inline SVGs - Add appendices/index.html, new Mermaid .mmd source files, matplotlib chart scripts Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1bd7ae2 commit 2a0be8a

860 files changed

Lines changed: 59362 additions & 18596 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CLAUDE.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,34 @@ When performing book production tasks, you MUST read the relevant agent descript
2424
- When **adding code captions**, read `agents/book-skills/agents/40-code-caption-agent.md`
2525
- When **auditing agent quality**, read `agents/book-skills/agents/36-meta-agent.md`
2626

27-
## Image Generation
27+
## Visual Content (Three Pipelines)
2828

29-
- Script: `agents/book-skills/scripts/generate_icons_gemini.py`
30-
- For multiple images, always use `--engine gemini --batch` (50% discount)
31-
- For single images, use `C:/Users/apart/.claude/skills/gemini-imagegen/scripts/generate_image.py`
29+
### 1. Gemini Illustrations (cartoons, visual metaphors)
30+
- Batch: `agents/book-skills/scripts/generate_icons_gemini.py` with `--engine gemini --batch` (50% discount)
31+
- Single: `C:/Users/apart/.claude/skills/gemini-imagegen/scripts/generate_image.py`
3232
- Prompt style: warm cartoon, whimsical, no text in images, Kurzgesagt meets XKCD
3333
- Embed with `<figure class="illustration">` pattern from `agents/book-skills/agents/31-illustrator.md`
3434

35+
### 2. Mermaid Diagrams (flowcharts, architectures, pipelines)
36+
- Render: `mmdc -i input.mmd -o output.png -c scripts/mermaid/mermaid-config.json -w 1200 -s 3 --backgroundColor white`
37+
- ELK layout (complex hierarchies): use `scripts/mermaid/mermaid-config-elk.json` instead
38+
- Source `.mmd` files saved alongside PNGs for future editing
39+
- Generation script: `scripts/mermaid/generate_mermaid_diagrams.py`
40+
- Dependencies: `@mermaid-js/mermaid-cli`, `@mermaid-js/layout-elk`
41+
- Embed with `<div class="diagram-container"><img>` pattern
42+
43+
### 3. Matplotlib Charts (data visualizations with axes)
44+
- Scripts: `scripts/svg_to_matplotlib/gen_figure_*.py`
45+
- Shared style: `scripts/svg_to_matplotlib/chart_style.py` (300 DPI, consistent fonts/colors)
46+
- Run: `C:/Python314/python scripts/svg_to_matplotlib/gen_figure_X_Y_Z.py`
47+
- Use `PchipInterpolator` for monotonic curves (avoids spline overshoot)
48+
49+
### Decision: which pipeline?
50+
- Cartoon/metaphor/humor → Gemini
51+
- Axes/data points/quantitative → Matplotlib
52+
- Boxes/arrows/flows/trees → Mermaid
53+
- Default (uncertain) → Mermaid (free, editable, consistent)
54+
3555
## Global Rules
3656
- NEVER use em dashes or double dashes in generated text
3757
- Use "book", "part", "chapter", "section", "reader" (not "course", "module", "lecture", "student")

agents/book-skills/agents/31-illustrator.md

Lines changed: 110 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,116 @@ humorous cartoon, or visual metaphor) would make it click instantly?"
2929

3030
## Responsibility Boundary
3131
- Does NOT enforce CSS, layout consistency, or visual identity standards; that is #25 Visual Identity Director.
32-
- Does NOT create SVG diagrams, flowcharts, or technical architecture figures; those are authored directly. This agent produces Gemini-generated cartoon/illustration assets only.
33-
- Does NOT write prose, captions for non-illustration figures, or alt text for existing SVG diagrams; content agents handle those.
32+
- Does NOT write prose, captions for non-illustration figures, or alt text for existing diagrams; content agents handle those.
33+
34+
## Three Illustration Pipelines
35+
36+
This agent supports THREE production pipelines for visual content. Choose the right tool for each situation:
37+
38+
### Pipeline 1: Gemini Image Generation (Cartoon Illustrations)
39+
**Use for:** Humorous cartoons, visual metaphors, mental model illustrations, chapter openers.
40+
**Tool:** Gemini Batch API (`batch_generate.py`) or single image (`generate_image.py`).
41+
**Output:** PNG files with warm, cartoon-like style (Kurzgesagt meets XKCD).
42+
**Cost:** ~$0.04/image (batch, 50% discount) or ~$0.08/image (sync).
43+
See the "Batch Image Generation Workflow" section below.
44+
45+
### Pipeline 2: Mermaid Diagrams (Flowcharts, Architectures, Pipelines)
46+
**Use for:** Flowcharts, decision trees, sequence diagrams, architecture diagrams, pipeline flows, tree structures, grouped/classified concept maps. Any diagram with boxes, arrows, and labels.
47+
**Tool:** Mermaid CLI (`mmdc`) with custom theme config.
48+
**Output:** High-resolution PNG at 3x scale with white background.
49+
**Cost:** Free (local rendering).
50+
51+
#### Mermaid Rendering Command
52+
```bash
53+
mmdc -i input.mmd -o output.png \
54+
-c E:/Projects/LLMCourse/scripts/mermaid/mermaid-config.json \
55+
-w 1200 -s 3 --backgroundColor white
56+
```
57+
58+
For complex hierarchical diagrams with many subgroups, use the ELK layout engine config:
59+
```bash
60+
mmdc -i input.mmd -o output.png \
61+
-c E:/Projects/LLMCourse/scripts/mermaid/mermaid-config-elk.json \
62+
-w 1200 -s 3 --backgroundColor white
63+
```
64+
65+
#### Mermaid Style Guidelines
66+
- Use HTML labels: `["<b>Title</b><br/><i>subtitle</i>"]`
67+
- Color palette (match book theme):
68+
- Blues: `fill:#e3f2fd,stroke:#1565c0,color:#1a1a2e`
69+
- Greens: `fill:#e8f5e9,stroke:#2e7d32,color:#1a1a2e`
70+
- Purples: `fill:#f3e5f5,stroke:#6a1b9a,color:#1a1a2e`
71+
- Oranges: `fill:#fff3e0,stroke:#e65100,color:#1a1a2e`
72+
- Reds: `fill:#fce4ec,stroke:#c62828,color:#1a1a2e`
73+
- Dark (emphasis): `fill:#1a1a2e,stroke:#0f3460,color:#fff`
74+
- Use `subgraph` for grouping related concepts
75+
- Use dashed arrows (`-.->`) for optional/feedback flows
76+
- Use solid arrows (`-->`) for primary flows
77+
- Add edge labels: `-->|"label"|`
78+
- Diagram types: `flowchart LR`, `flowchart TB`, `flowchart TD`, `sequenceDiagram`, `classDiagram`
79+
80+
#### Mermaid Diagram Template
81+
```mermaid
82+
flowchart LR
83+
A["<b>Step 1</b><br/><i>description</i>"]
84+
B["<b>Step 2</b><br/><i>description</i>"]
85+
C["<b>Step 3</b><br/><i>description</i>"]
86+
87+
A -->|"action"| B -->|"action"| C
88+
89+
style A fill:#e3f2fd,stroke:#1565c0,stroke-width:2px,color:#1a1a2e
90+
style B fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px,color:#1a1a2e
91+
style C fill:#f3e5f5,stroke:#6a1b9a,stroke-width:2px,color:#1a1a2e
92+
```
93+
94+
#### Mermaid HTML Embedding
95+
```html
96+
<div class="diagram-container">
97+
<img src="images/descriptive-name.png" alt="Description of diagram" loading="lazy" style="max-width: 100%;">
98+
<div class="diagram-caption"><strong>Figure X.Y.Z</strong>: Caption describing the concept.</div>
99+
</div>
100+
```
101+
102+
#### Existing Mermaid Infrastructure
103+
- Config files: `scripts/mermaid/mermaid-config.json` (dagre, default), `scripts/mermaid/mermaid-config-elk.json` (ELK, complex layouts)
104+
- Generation script: `scripts/mermaid/generate_mermaid_diagrams.py` (with `render_mermaid()` helper)
105+
- Save `.mmd` source files alongside PNGs for future editing
106+
- Dependencies: `npm install -g @mermaid-js/mermaid-cli @mermaid-js/layout-elk`
107+
108+
### Pipeline 3: Matplotlib Charts (Data Visualizations)
109+
**Use for:** Line charts, bar charts, scatter plots, radar charts, any diagram with axes, data points, or quantitative comparisons.
110+
**Tool:** Python matplotlib with shared style module.
111+
**Output:** 300 DPI PNG with consistent typography and colors.
112+
**Cost:** Free (local rendering).
113+
114+
#### Matplotlib Rendering
115+
```bash
116+
C:/Python314/python scripts/svg_to_matplotlib/gen_figure_X_Y_Z.py
117+
```
118+
119+
#### Matplotlib Style Module
120+
All chart scripts import `chart_style.py` from `scripts/svg_to_matplotlib/`:
121+
```python
122+
import sys, os
123+
sys.path.insert(0, os.path.dirname(__file__))
124+
from chart_style import *
125+
apply_style()
126+
```
127+
128+
This provides: `plt`, `np`, `save_figure()`, consistent font sizes, color palette, and 300 DPI output.
129+
130+
#### Matplotlib Guidelines
131+
- Use `PchipInterpolator` (not `make_interp_spline`) for monotonic curves to avoid overshoot artifacts
132+
- Color palette: `#1a4a80` (primary blue), `#e94560` (accent red), `#27ae60` (green), `#f39c12` (orange)
133+
- Always include axis labels, use `fontsize=12, color='#555'`
134+
- Remove top/right spines: `ax.spines['top'].set_visible(False)`
135+
- Use `fig, ax = plt.subplots(figsize=(10, 5.5))` for standard charts
136+
137+
### Pipeline Selection Decision Tree
138+
1. Is it a **cartoon, metaphor, or humorous scene**? → Gemini
139+
2. Does it have **axes, data points, or quantitative data**? → Matplotlib
140+
3. Is it a **flowchart, architecture, pipeline, decision tree, or grouped concept map**? → Mermaid
141+
4. When in doubt, prefer **Mermaid** (free, editable, consistent styling)
34142

35143
## Batch Image Generation Workflow
36144

appendices/appendix-a-mathematical-foundations/section-a.5.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ <h2>What Comes Next</h2>
9393
</div>
9494

9595
<div class="bib-entry-card">
96-
<p class="bib-ref">Shannon, C. E. (1948). "A Mathematical Theory of Communication." Bell System Technical Journal, 27(3), 379-423.</p>
96+
<p class="bib-ref">
97+
Shannon, C. E. (1948). <a href="https://doi.org/10.1002/j.1538-7305.1948.tb01338.x" target="_blank" rel="noopener">"A Mathematical Theory of Communication."</a> Bell System Technical Journal, 27(3), 379-423.
98+
</p>
9799
<p class="bib-annotation">The founding paper of information theory. Still remarkably readable.</p>
98100
<span class="bib-meta">Foundational Paper</span>
99101
</div>

appendices/appendix-b-ml-essentials/section-b.4.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,17 @@ <h2>What Comes Next</h2>
234234
<div class="bib-category">Metrics and Evaluation</div>
235235

236236
<div class="bib-entry-card">
237-
<p class="bib-ref">Papineni, K. et al. (2002). "BLEU: a Method for Automatic Evaluation of Machine Translation." ACL 2002.</p>
237+
<p class="bib-ref">
238+
Papineni, K. et al. (2002). <a href="https://doi.org/10.3115/1073083.1073135" target="_blank" rel="noopener">"BLEU: a Method for Automatic Evaluation of Machine Translation."</a> ACL 2002.
239+
</p>
238240
<p class="bib-annotation">The original BLEU paper, still one of the most cited works in NLP evaluation.</p>
239241
<span class="bib-meta">Foundational Paper</span>
240242
</div>
241243

242244
<div class="bib-entry-card">
243-
<p class="bib-ref">Zhang, T. et al. (2020). "BERTScore: Evaluating Text Generation with BERT." ICLR 2020.</p>
245+
<p class="bib-ref">
246+
Zhang, T. et al. (2020). <a href="https://arxiv.org/abs/1904.09675" target="_blank" rel="noopener">"BERTScore: Evaluating Text Generation with BERT."</a> ICLR 2020.
247+
</p>
244248
<p class="bib-annotation">Embedding-based evaluation that better captures semantic similarity than n-gram methods.</p>
245249
<span class="bib-meta">Research Paper</span>
246250
</div>
-261 KB
Loading
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
flowchart LR
2+
UI["<b>User Input</b>"]
3+
LLM["<b>LLM</b><br/><i>decides action</i>"]
4+
TOOL["<b>Tool</b><br/><i>execute</i>"]
5+
FA["<b>Final Answer</b><br/><i>no more tools</i>"]
6+
7+
UI --> LLM
8+
LLM -->|"tool call"| TOOL
9+
TOOL -.->|"observation"| LLM
10+
LLM -->|"done"| FA
11+
12+
style UI fill:#d6eaf8,stroke:#2980b9,stroke-width:2px,color:#1a5276
13+
style LLM fill:#d5f5e3,stroke:#27ae60,stroke-width:2px,color:#1e8449
14+
style TOOL fill:#fdebd0,stroke:#e67e22,stroke-width:2px,color:#935116
15+
style FA fill:#e8daef,stroke:#8e44ad,stroke-width:2px,color:#4a235a
48.6 KB
Loading
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
flowchart LR
2+
A["<b>PromptTemplate</b><br/><i>fills variables</i>"]
3+
B["<b>ChatModel</b><br/><i>generates response</i>"]
4+
C["<b>OutputParser</b><br/><i>extracts content</i>"]
5+
D["<b>Result</b><br/><i>clean string</i>"]
6+
7+
A -->|"&nbsp;pipe&nbsp;"| B -->|"&nbsp;pipe&nbsp;"| C -->|"&nbsp;pipe&nbsp;"| D
8+
9+
style A fill:#e8daef,stroke:#8e44ad,stroke-width:2px,color:#4a235a
10+
style B fill:#d5f5e3,stroke:#27ae60,stroke-width:2px,color:#1e8449
11+
style C fill:#fdebd0,stroke:#e67e22,stroke-width:2px,color:#935116
12+
style D fill:#d6eaf8,stroke:#2980b9,stroke-width:2px,color:#1a5276
46.9 KB
Loading
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
flowchart LR
2+
UI["<b>User Input</b>"]
3+
RWM["<b>RunnableWith<br/>MessageHistory</b>"]
4+
HS["<b>History Store</b><br/><i>get_session_history</i>"]
5+
CH["<b>LCEL Chain</b>"]
6+
RS["<b>Response</b>"]
7+
8+
UI --> RWM
9+
HS -.->|"load history"| RWM
10+
RWM --> CH --> RS
11+
CH -.->|"save exchange"| HS
12+
13+
style UI fill:#d6eaf8,stroke:#2980b9,stroke-width:2px,color:#1a5276
14+
style RWM fill:#e8daef,stroke:#8e44ad,stroke-width:2px,color:#4a235a
15+
style HS fill:#fdebd0,stroke:#e67e22,stroke-width:2px,color:#935116
16+
style CH fill:#d5f5e3,stroke:#27ae60,stroke-width:2px,color:#1e8449
17+
style RS fill:#d6eaf8,stroke:#2980b9,stroke-width:2px,color:#1a5276

0 commit comments

Comments
 (0)