Skip to content

Commit 67dfa59

Browse files
sanbuphyclaude
andcommitted
Add mermaid diagrams to all lectures, PDF build pipeline, and README screenshots
- Add 1-2 mermaid diagrams per lecture (EN + ZH, 24 files total) illustrating core concepts: five-layer failure model, harness subsystems, knowledge visibility, instruction architecture, session continuity, initialization lifecycle, WIP=1 workflow, feature state machine, termination checks, test pyramid, observability layers, and clean state dimensions - Add PDF build pipeline: scripts/build-course-pdfs.ts and npm scripts - Add README screenshot capture script and workflow - Add GitHub Actions workflow for automated PDF releases - Update README/README-CN with screenshots and PDF documentation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1ebca82 commit 67dfa59

40 files changed

Lines changed: 1402 additions & 1 deletion

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Build course PDFs and publish release assets
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: Release tag to create or update
8+
required: true
9+
type: string
10+
release_name:
11+
description: Release title
12+
required: true
13+
type: string
14+
prerelease:
15+
description: Mark release as prerelease
16+
required: false
17+
default: false
18+
type: boolean
19+
release:
20+
types:
21+
- published
22+
23+
permissions:
24+
contents: write
25+
26+
jobs:
27+
build-pdfs:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v5
32+
with:
33+
fetch-depth: 0
34+
35+
- name: Setup Node
36+
uses: actions/setup-node@v6
37+
with:
38+
node-version: 24
39+
cache: npm
40+
41+
- name: Install dependencies
42+
run: npm ci
43+
44+
- name: Install Chromium for Playwright
45+
run: npx playwright install --with-deps chromium
46+
47+
- name: Build course PDFs
48+
run: npm run pdf:build
49+
50+
- name: Upload PDF artifacts
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: course-pdfs
54+
path: artifacts/pdfs
55+
56+
- name: Publish PDFs to existing release
57+
if: github.event_name == 'release'
58+
uses: softprops/action-gh-release@v2
59+
with:
60+
tag_name: ${{ github.event.release.tag_name }}
61+
files: artifacts/pdfs/*.pdf
62+
63+
- name: Create or update release with PDFs
64+
if: github.event_name == 'workflow_dispatch'
65+
uses: softprops/action-gh-release@v2
66+
with:
67+
tag_name: ${{ inputs.tag }}
68+
name: ${{ inputs.release_name }}
69+
prerelease: ${{ inputs.prerelease }}
70+
generate_release_notes: true
71+
files: artifacts/pdfs/*.pdf

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ pnpm-debug.log*
2626
docs/.vitepress/cache/
2727
docs/.vitepress/dist/
2828
*.tsbuildinfo
29+
artifacts/

README-CN.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,35 @@ Learn Harness Engineering 是一门专注于 AI 编程智能体工程化落地
1313

1414
---
1515

16+
## 页面截图
17+
18+
### 中文
19+
20+
<p>
21+
<img src="./docs/public/screenshots/readme/zh-home.png" alt="中文首页预览" width="32%" />
22+
<img src="./docs/public/screenshots/readme/zh-lecture-01.png" alt="中文讲义预览" width="32%" />
23+
<img src="./docs/public/screenshots/readme/zh-resources.png" alt="中文资料库预览" width="32%" />
24+
</p>
25+
26+
### English
27+
28+
<p>
29+
<img src="./docs/public/screenshots/readme/en-home.png" alt="English homepage preview" width="32%" />
30+
<img src="./docs/public/screenshots/readme/en-lecture-01.png" alt="English lecture preview" width="32%" />
31+
<img src="./docs/public/screenshots/readme/en-resources.png" alt="English resources preview" width="32%" />
32+
</p>
33+
34+
## PDF 构建与 Release 流水线
35+
36+
仓库里现在已经补上了课程 PDF 的构建链路。
37+
38+
- 本地执行 `npm run pdf:build`,会生成中英文两份课程 PDF。
39+
- 输出目录是 `artifacts/pdfs/`
40+
- 如果需要刷新 README 里的截图,执行 `npm run screenshots:readme`
41+
- GitHub Actions 工作流 [`release-course-pdfs.yml`](./.github/workflows/release-course-pdfs.yml) 可以自动构建 PDF,并把产物上传到 GitHub Release。
42+
43+
---
44+
1645
## 模型很强,但 Harness 让它靠谱
1746

1847
有一个很多人交过学费才明白的事实:**世界上最强的模型,如果没有一个合适的工作环境,依然会在真实工程任务中翻车。**

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,35 @@ Learn Harness Engineering is a course dedicated to the engineering of AI coding
1313

1414
---
1515

16+
## Visual Preview
17+
18+
### English
19+
20+
<p>
21+
<img src="./docs/public/screenshots/readme/en-home.png" alt="English homepage preview" width="32%" />
22+
<img src="./docs/public/screenshots/readme/en-lecture-01.png" alt="English lecture preview" width="32%" />
23+
<img src="./docs/public/screenshots/readme/en-resources.png" alt="English resources preview" width="32%" />
24+
</p>
25+
26+
### 中文
27+
28+
<p>
29+
<img src="./docs/public/screenshots/readme/zh-home.png" alt="中文首页预览" width="32%" />
30+
<img src="./docs/public/screenshots/readme/zh-lecture-01.png" alt="中文讲义预览" width="32%" />
31+
<img src="./docs/public/screenshots/readme/zh-resources.png" alt="中文资料库预览" width="32%" />
32+
</p>
33+
34+
## PDF Coursebooks
35+
36+
The repository now includes a PDF build pipeline for the course content.
37+
38+
- Run `npm run pdf:build` to generate English and Chinese PDFs locally.
39+
- Output files are written to `artifacts/pdfs/`.
40+
- Run `npm run screenshots:readme` if you want to refresh the README preview images.
41+
- GitHub Actions workflow [`release-course-pdfs.yml`](./.github/workflows/release-course-pdfs.yml) can build the PDFs and publish them to GitHub Releases.
42+
43+
---
44+
1645
## The Model Is Smart, The Harness Makes It Reliable
1746

1847
There's a hard truth most people learn the hard way: **the strongest model in the world will still fail on real engineering tasks if you don't build a proper environment around it.**

docs/en/lectures/lecture-01-why-capable-agents-still-fail/index.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,31 @@ This isn't because the model isn't smart enough. It's because the working enviro
2020
- **Diagnostic Loop**: Execute → observe failure → attribute to a specific harness layer → fix that layer → re-execute. This is the core methodology of harness engineering.
2121
- **Definition of Done**: A set of machine-verifiable conditions — tests pass, lint is clean, type checks pass. Without an explicit definition of done, the agent will invent its own.
2222

23+
## Failure Model Overview
24+
25+
```mermaid
26+
graph LR
27+
subgraph "Five Failure Layers"
28+
direction TB
29+
L1["① Task Specification"]
30+
L2["② Context Provision"]
31+
L3["③ Execution Environment"]
32+
L4["④ Verification Feedback"]
33+
L5["⑤ State Management"]
34+
end
35+
36+
Agent -->|"encounters"| L1
37+
L1 --> L2 --> L3 --> L4 --> L5
38+
L5 -->|"signals defect"| Fix["Fix layer → Re-run"]
39+
Fix -->|"diagnostic loop"| Agent
40+
```
41+
42+
```mermaid
43+
graph LR
44+
Bare["Bare Run<br/>20 min / $9<br/>Core features broken"] -->|"Add harness"| Full["Full Harness<br/>6 hr / $200<br/>Playable app"]
45+
Bare -.->|"Same model"| Full
46+
```
47+
2348
## Why This Happens
2449

2550
Let's start with data. As of late 2025, the strongest coding agents on SWE-bench Verified achieve roughly 50-60%. And that's on carefully selected tasks with clear issue descriptions and existing test cases. Move to a real daily development scenario — vague requirements, no existing tests, implicit business rules scattered everywhere — and that number only goes down.

docs/en/lectures/lecture-02-what-a-harness-actually-is/index.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,21 @@ This lecture gives you a precise, actionable definition. Not an academic abstrac
2020
- **Feedback Latency**: The time between an agent's action and the feedback it receives. Compilation errors are second-level feedback, test suites are minute-level, "bug in production" is day-level. Faster feedback means faster correction.
2121
- **Isometric Model Control**: Keep the model fixed, systematically vary harness subsystems, measure each one's marginal contribution. This is the correct way to quantify a harness's value.
2222

23+
## The Five-Tuple Harness Model
24+
25+
```mermaid
26+
graph TB
27+
Agent["AI Agent"] --> I["📋 Instructions<br/><i>AGENTS.md, CLAUDE.md</i>"]
28+
Agent --> T["🔧 Tools<br/><i>Shell, file ops, tests</i>"]
29+
Agent --> E["🖥️ Environment<br/><i>Dependencies, runtime</i>"]
30+
Agent --> S["💾 State<br/><i>Progress files, git</i>"]
31+
Agent --> F["✅ Feedback<br/><i>Test results, lint, build</i>"]
32+
33+
I ~~~ T ~~~ E ~~~ S ~~~ F
34+
35+
F -->|"highest ROI"| Star["⭐ Start here"]
36+
```
37+
2338
## Why This Happens
2439

2540
Here's an analogy. Imagine you're a newly hired engineer dropped into a project with zero documentation. No README, no comments in the code, nobody tells you how to run tests, CI config is buried somewhere. Can you write good code? Maybe, but you'll spend enormous time on "figuring out what this project is about" rather than "solving the problem."

docs/en/lectures/lecture-03-why-the-repository-must-become-the-system-of-record/index.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,39 @@ This lecture explains why you must put everything an agent needs to know into th
2020
- **Knowledge Decay Rate**: The proportion of knowledge entries that become stale per unit of time. Documentation going out of sync with code is the biggest enemy.
2121
- **ACID for Agent State**: Applying database transaction principles (Atomicity, Consistency, Isolation, Durability) to agent state management.
2222

23+
## Knowledge Visibility
24+
25+
```mermaid
26+
graph LR
27+
subgraph "Visible to Agent"
28+
Repo["Repository Files<br/>AGENTS.md, code, tests"]
29+
end
30+
subgraph "Invisible to Agent"
31+
Slack["Slack History"]
32+
Confluence["Confluence Docs"]
33+
Heads["Senior Engineers' Heads"]
34+
Jira["Jira Tickets"]
35+
end
36+
37+
Repo -->|"accessible"| Agent["🤖 Agent"]
38+
Slack -.->|"inaccessible"| Agent
39+
Confluence -.->|"inaccessible"| Agent
40+
Heads -.->|"inaccessible"| Agent
41+
Jira -.->|"inaccessible"| Agent
42+
```
43+
44+
```mermaid
45+
graph TB
46+
subgraph "Cold-Start Test"
47+
Q1["What is this system?"]
48+
Q2["How is it organized?"]
49+
Q3["How do I run it?"]
50+
Q4["How do I verify it?"]
51+
Q5["Where are we now?"]
52+
end
53+
Q1 & Q2 & Q3 & Q4 & Q5 -->|"all must be<br/>answerable from repo"| Pass["✅ Harness Ready"]
54+
```
55+
2356
## Why This Happens
2457

2558
Think about what an agent's inputs actually are: system prompts and task descriptions, file contents from the repository, and tool execution output. That's it. Your Slack history, Jira tickets, Confluence pages, and that architecture decision you discussed with a colleague over coffee on Friday afternoon — the agent can't see any of it.

docs/en/lectures/lecture-04-why-one-giant-instruction-file-fails/index.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,31 @@ This is the "giant instruction file" trap. This lecture explains why "more infor
2020
- **Progressive Disclosure**: Give overview information first, detailed information when needed. Good harness design is like good UI design — don't dump all options on the user at once.
2121
- **Priority Ambiguity**: When all instructions appear in the same format and location, the agent can't distinguish non-negotiable hard constraints from suggestive soft guidelines.
2222

23+
## Instruction Architecture
24+
25+
```mermaid
26+
graph TB
27+
subgraph "Three-Layer Structure"
28+
L1["<b>Layer 1: Routing File</b><br/>AGENTS.md (50–200 lines)<br/>Overview + hard constraints + links"]
29+
L2a["<b>Layer 2a</b><br/>api-patterns.md"]
30+
L2b["<b>Layer 2b</b><br/>database-rules.md"]
31+
L2c["<b>Layer 2c</b><br/>testing-standards.md"]
32+
L3["<b>Layer 3: Inline</b><br/>Type defs, interface comments"]
33+
end
34+
35+
L1 -->|"link"| L2a
36+
L1 -->|"link"| L2b
37+
L1 -->|"link"| L2c
38+
L2a & L2b & L2c -->|"reference"| L3
39+
40+
style L1 fill:#D95C41,color:#fff
41+
```
42+
43+
```mermaid
44+
graph LR
45+
Top["Top of file<br/>✅ High recall"] --- Mid["Middle of file<br/>❌ Lost in the middle"] --- Bot["Bottom of file<br/>✅ High recall"]
46+
```
47+
2348
## Why This Happens
2449

2550
The most common vicious cycle goes like this: the agent makes a mistake → you say "add a rule to prevent this" → add it to AGENTS.md → it works temporarily → agent makes a different mistake → add another rule → repeat → file bloats out of control.

docs/en/lectures/lecture-05-why-long-running-tasks-lose-continuity/index.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,30 @@ This is one of the most painful problems with AI coding agents: cross-session co
2020
- **Compaction vs Reset**: Compaction summarizes context within the same session (keeps "what," may lose "why"); reset opens a new session rebuilding from persisted state (clean but depends on artifact completeness).
2121
- **Context Anxiety**: A phenomenon observed by Anthropic — agents exhibit premature convergence behavior when approaching perceived context limits, ending tasks early to avoid information loss. It's an irrational resource anxiety.
2222

23+
## Session Continuity Flow
24+
25+
```mermaid
26+
graph LR
27+
subgraph "Session N"
28+
Work1["Work on task"] --> Update1["Update PROGRESS.md<br/>Update DECISIONS.md"]
29+
Update1 --> Commit1["Git commit checkpoint"]
30+
end
31+
subgraph "Session N+1"
32+
Read1["Read PROGRESS.md<br/>Read DECISIONS.md"] --> Resume["Resume from<br/>Next Steps"]
33+
Resume --> Work2["Continue work"]
34+
end
35+
36+
Commit1 -->|"handoff"| Read1
37+
```
38+
39+
```mermaid
40+
graph TB
41+
subgraph "Information Loss"
42+
Full["Full Context<br/>What + Why + How"] -->|"compaction"| Compact["Compacted<br/>What ✓ · Why ✗"]
43+
Full -->|"new session"| Reset["Reset<br/>Rebuild from artifacts"]
44+
end
45+
```
46+
2347
## Why This Happens
2448

2549
Context windows are finite. This isn't solvable by model upgrades — even if window sizes grow to 1M tokens, complex tasks will still exhaust them. Because agents aren't just generating code; they're understanding codebases, tracking their own decision history, processing tool output, and maintaining conversation context. All this information grows faster than window expansion.

docs/en/lectures/lecture-06-why-initialization-needs-its-own-phase/index.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,29 @@ The better approach: before letting the agent start working, use a separate phas
2020
- **Time to First Verification**: The time from project start until the first feature point passes verification. This is the core metric for measuring initialization efficiency.
2121
- **Downstream Usability**: The best measure of initialization quality — the proportion of subsequent sessions that can successfully execute tasks without relying on implicit knowledge.
2222

23+
## Initialization Lifecycle
24+
25+
```mermaid
26+
graph LR
27+
subgraph "Initialization Phase"
28+
I1["Runnable environment<br/><i>deps installed</i>"] --> I2["Test framework<br/><i>example test passes</i>"]
29+
I2 --> I3["Bootstrap contract<br/><i>start/test/verify docs</i>"]
30+
I3 --> I4["Task breakdown<br/><i>ordered feature list</i>"]
31+
I4 --> I5["Git checkpoint<br/><i>clean commit</i>"]
32+
end
33+
subgraph "Implementation Phase"
34+
I5 --> P1["Session 2: Feature 1"]
35+
P1 --> P2["Session 3: Feature 2"]
36+
P2 --> P3["Session N: Feature N"]
37+
end
38+
39+
style I1 fill:#D95C41,color:#fff
40+
style I2 fill:#D95C41,color:#fff
41+
style I3 fill:#D95C41,color:#fff
42+
style I4 fill:#D95C41,color:#fff
43+
style I5 fill:#D95C41,color:#fff
44+
```
45+
2346
## Why This Happens
2447

2548
Initialization and implementation have fundamentally different optimization targets. The implementation phase optimizes for: maximizing the quantity and quality of verified features. The initialization phase optimizes for: maximizing the reliability and efficiency of all subsequent implementation.

0 commit comments

Comments
 (0)