@brandon_m_behring/book-scaffold-astro 3.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +179 -0
- package/bin/book-scaffold.mjs +61 -0
- package/components/CaseStudy.astro +36 -0
- package/components/ChapterHeader.astro +61 -0
- package/components/ChapterNav.astro +29 -0
- package/components/ChapterTOC.astro +33 -0
- package/components/Citation.astro +94 -0
- package/components/Cite.astro +71 -0
- package/components/CodeBlock.astro +115 -0
- package/components/CodeRef.astro +49 -0
- package/components/ConceptBox.astro +26 -0
- package/components/Convergence.astro +41 -0
- package/components/CounterBox.astro +15 -0
- package/components/Divergence.astro +32 -0
- package/components/DynConnect.astro +15 -0
- package/components/ExampleBox.astro +15 -0
- package/components/Figure.astro +35 -0
- package/components/InsightBox.astro +15 -0
- package/components/KeyIdea.astro +21 -0
- package/components/MarginNote.astro +37 -0
- package/components/NoteBox.astro +15 -0
- package/components/OpenQuestion.astro +15 -0
- package/components/PaperBox.astro +15 -0
- package/components/PatternTimeline.astro +133 -0
- package/components/Recovery.astro +34 -0
- package/components/ResultBox.astro +15 -0
- package/components/Sidebar.astro +268 -0
- package/components/Sidenote.astro +26 -0
- package/components/SkillBox.astro +24 -0
- package/components/SourceArchive.astro +285 -0
- package/components/StatusBadge.astro +51 -0
- package/components/Tag.astro +60 -0
- package/components/Theorem.astro +65 -0
- package/components/TipBox.astro +15 -0
- package/components/ToolFilter.tsx +160 -0
- package/components/TryThis.astro +23 -0
- package/components/VersionSelector.tsx +85 -0
- package/components/WarnBox.astro +15 -0
- package/components/WeekRef.astro +51 -0
- package/components/XRef.astro +40 -0
- package/dist/index.d.ts +135 -0
- package/dist/index.mjs +369 -0
- package/dist/lib/katex-macros.d.ts +26 -0
- package/dist/lib/katex-macros.mjs +98 -0
- package/dist/schemas.d.ts +17 -0
- package/dist/schemas.mjs +160 -0
- package/dist/types-Cz-pwE1N.d.ts +61 -0
- package/examples/chapter-template-academic.mdx +100 -0
- package/examples/chapter-template-tools.mdx +90 -0
- package/layouts/Base.astro +250 -0
- package/layouts/Chapter.astro +37 -0
- package/package.json +137 -0
- package/pages/chapters.astro +371 -0
- package/pages/convergence.astro +96 -0
- package/pages/print.astro +39 -0
- package/pages/references.astro +160 -0
- package/pages/search.astro +87 -0
- package/pedagogy/kf-chapter-shape.md +96 -0
- package/pedagogy/source-tiers.md +121 -0
- package/pedagogy/volatility-classes.md +110 -0
- package/recipes/00-getting-started.md +77 -0
- package/recipes/01-add-math.md +71 -0
- package/recipes/02-bibliography-pipeline.md +82 -0
- package/recipes/03-asset-pipelines.md +84 -0
- package/recipes/04-component-library.md +118 -0
- package/recipes/05-deploy-cloudflare.md +74 -0
- package/recipes/06-mobile-first-layout.md +73 -0
- package/recipes/07-chapter-shapes.md +84 -0
- package/recipes/08-decisions-ledger.md +110 -0
- package/recipes/09-validation.md +106 -0
- package/recipes/10-custom-domain.md +72 -0
- package/recipes/README.md +43 -0
- package/scripts/build-bib.mjs +99 -0
- package/scripts/build-figures.mjs +179 -0
- package/scripts/render-notebooks.mjs +223 -0
- package/scripts/validate.mjs +179 -0
- package/styles/callouts.css +303 -0
- package/styles/chapter.css +209 -0
- package/styles/convergence.css +349 -0
- package/styles/layout.css +156 -0
- package/styles/print.css +203 -0
- package/styles/tokens.css +194 -0
- package/styles/tool-filter.css +135 -0
- package/styles/typography.css +147 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* search.astro — full-page Pagefind search UI.
|
|
4
|
+
*
|
|
5
|
+
* The Pagefind index is generated at build time by `pagefind --site dist`
|
|
6
|
+
* (see package.json). This page is the interactive entry point: users
|
|
7
|
+
* land here via the header search icon and type queries; Pagefind's
|
|
8
|
+
* bundled UI renders results with excerpts from indexed chapters.
|
|
9
|
+
*
|
|
10
|
+
* CSS/JS paths (/pagefind/*) only exist after the build step, not in
|
|
11
|
+
* `astro dev`. See README for dev-search workflow.
|
|
12
|
+
*/
|
|
13
|
+
import Base from '../layouts/Base.astro';
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
<Base
|
|
17
|
+
title="Search · book-template-astro"
|
|
18
|
+
description="Full-text search across the book. Indexed via Pagefind at build time; all queries run in the browser."
|
|
19
|
+
>
|
|
20
|
+
<link rel="stylesheet" href="/pagefind/pagefind-ui.css" slot="head" />
|
|
21
|
+
|
|
22
|
+
<main class="prose search-page">
|
|
23
|
+
<h1>Search</h1>
|
|
24
|
+
<p>
|
|
25
|
+
Full-text search runs in your browser. The index is generated at
|
|
26
|
+
build time and is less than 100 KB total — queries never leave
|
|
27
|
+
the page.
|
|
28
|
+
</p>
|
|
29
|
+
<div id="search"></div>
|
|
30
|
+
</main>
|
|
31
|
+
|
|
32
|
+
<script src="/pagefind/pagefind-ui.js" is:inline></script>
|
|
33
|
+
<script is:inline>
|
|
34
|
+
// Initialize after the Pagefind bundle has loaded.
|
|
35
|
+
window.addEventListener('DOMContentLoaded', () => {
|
|
36
|
+
if (typeof window.PagefindUI === 'function') {
|
|
37
|
+
new window.PagefindUI({
|
|
38
|
+
element: '#search',
|
|
39
|
+
showImages: false,
|
|
40
|
+
showSubResults: true,
|
|
41
|
+
resetStyles: false,
|
|
42
|
+
});
|
|
43
|
+
} else {
|
|
44
|
+
document.getElementById('search').innerHTML =
|
|
45
|
+
'<p><em>Search index not found. Run <code>npm run build</code> first; dev mode does not include the index.</em></p>';
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<style is:global>
|
|
51
|
+
/* Tame PagefindUI defaults to match the book's typography + palette. */
|
|
52
|
+
.pagefind-ui__form {
|
|
53
|
+
margin-top: var(--space-4);
|
|
54
|
+
}
|
|
55
|
+
.pagefind-ui__search-input {
|
|
56
|
+
font-family: var(--font-body) !important;
|
|
57
|
+
font-size: var(--text-base) !important;
|
|
58
|
+
padding: var(--space-3) !important;
|
|
59
|
+
border: 1px solid var(--color-border) !important;
|
|
60
|
+
border-radius: var(--radius-md) !important;
|
|
61
|
+
background: var(--color-bg-subtle) !important;
|
|
62
|
+
color: var(--color-text) !important;
|
|
63
|
+
}
|
|
64
|
+
.pagefind-ui__search-input:focus {
|
|
65
|
+
border-color: var(--color-link) !important;
|
|
66
|
+
outline: 2px solid color-mix(in srgb, var(--color-link) 30%, transparent);
|
|
67
|
+
}
|
|
68
|
+
.pagefind-ui__result {
|
|
69
|
+
border-bottom: 1px solid var(--color-border) !important;
|
|
70
|
+
padding: var(--space-3) 0 !important;
|
|
71
|
+
}
|
|
72
|
+
.pagefind-ui__result-link {
|
|
73
|
+
color: var(--color-link) !important;
|
|
74
|
+
font-weight: 500 !important;
|
|
75
|
+
}
|
|
76
|
+
.pagefind-ui__result-excerpt {
|
|
77
|
+
color: var(--color-text) !important;
|
|
78
|
+
font-size: var(--text-sm) !important;
|
|
79
|
+
}
|
|
80
|
+
.pagefind-ui__result-excerpt mark {
|
|
81
|
+
background: var(--warm-gold-tint);
|
|
82
|
+
color: var(--color-text);
|
|
83
|
+
padding: 0 0.15em;
|
|
84
|
+
border-radius: var(--radius-sm);
|
|
85
|
+
}
|
|
86
|
+
</style>
|
|
87
|
+
</Base>
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Koller-Friedman chapter shape
|
|
2
|
+
|
|
3
|
+
Every chapter in a book-scaffold-astro project uses a uniform three-part
|
|
4
|
+
skeleton: **Representation**, **Operation**, **Evolution**. The idea
|
|
5
|
+
comes from Daphne Koller and Nir Friedman's *Probabilistic Graphical
|
|
6
|
+
Models: Principles and Techniques* (MIT Press, 2009), where every
|
|
7
|
+
chapter on a graphical model type follows this sequence.
|
|
8
|
+
|
|
9
|
+
## The three parts
|
|
10
|
+
|
|
11
|
+
### Representation
|
|
12
|
+
|
|
13
|
+
What is the thing, conceptually? Define the object the chapter is
|
|
14
|
+
about. Give its structural properties, its type signature, the
|
|
15
|
+
invariants that make it itself. Answer: **what are we looking at?**
|
|
16
|
+
|
|
17
|
+
A chapter on agents might define: what an agent is as a computational
|
|
18
|
+
object; what makes an agent distinct from a script; what invariants
|
|
19
|
+
(context, tools, permissions) every agent carries.
|
|
20
|
+
|
|
21
|
+
### Operation
|
|
22
|
+
|
|
23
|
+
How does the thing behave? Show the dynamics — how it's used, how it
|
|
24
|
+
fails, how it composes. Include the verification / testing perspective.
|
|
25
|
+
Answer: **what does it do, and how do we know it's doing the right
|
|
26
|
+
thing?**
|
|
27
|
+
|
|
28
|
+
For the same agent chapter, Operation would cover: the session loop,
|
|
29
|
+
how agents consume context, how multi-step tasks decompose, common
|
|
30
|
+
failure modes, and how to detect them.
|
|
31
|
+
|
|
32
|
+
### Evolution
|
|
33
|
+
|
|
34
|
+
How does the thing change over time? Show comparative and historical
|
|
35
|
+
evidence. This is where the book's "convergence / divergence" callouts
|
|
36
|
+
live — which tools adopted this pattern, when, and where they still
|
|
37
|
+
differ. Answer: **is this idea stable, or is it still being argued?**
|
|
38
|
+
|
|
39
|
+
For the agent chapter, Evolution would cover: when each tool shipped
|
|
40
|
+
agent primitives, which design decisions converged, what's still open.
|
|
41
|
+
|
|
42
|
+
## Why this shape
|
|
43
|
+
|
|
44
|
+
Three reasons:
|
|
45
|
+
|
|
46
|
+
1. **Drift-resistance.** When every chapter looks the same structurally,
|
|
47
|
+
the skeleton is legible at a glance. Drift into feature documentation
|
|
48
|
+
becomes visible because it won't fit the shape. A chapter that
|
|
49
|
+
accidentally turns into a feature catalogue has no Evolution section
|
|
50
|
+
— the gap is the alarm.
|
|
51
|
+
|
|
52
|
+
2. **Reader fluency.** A reader learns the skeleton once and reads every
|
|
53
|
+
subsequent chapter fluently. They know where to find the invariants
|
|
54
|
+
(Representation), where to find the failure modes (Operation), and
|
|
55
|
+
where to find the historical context (Evolution). No hunting.
|
|
56
|
+
|
|
57
|
+
3. **Comparative pedagogy.** The Evolution section makes cross-tool
|
|
58
|
+
comparison first-class. When tools converge on a pattern, the
|
|
59
|
+
Convergence callout renders in gold. When tools diverge on a
|
|
60
|
+
design choice, the Divergence callout renders with a dashed
|
|
61
|
+
accent. Neither is hidden; both are expected.
|
|
62
|
+
|
|
63
|
+
## How the scaffold enforces this
|
|
64
|
+
|
|
65
|
+
The scaffold doesn't validate chapter structure at build time (too
|
|
66
|
+
brittle), but it ships visual affordances that make the structure
|
|
67
|
+
visible:
|
|
68
|
+
|
|
69
|
+
- `/chapters/` index renders volatility + freshness + tools badges on
|
|
70
|
+
every card — the reader sees the Evolution metadata before they even
|
|
71
|
+
open the chapter.
|
|
72
|
+
- `Convergence` and `Divergence` callouts signal stability state
|
|
73
|
+
within a chapter. Both live in the Evolution section by convention.
|
|
74
|
+
- `last_verified` + `volatility` frontmatter fields power the freshness
|
|
75
|
+
badge. Since freshness is tied to volatility class, Evolution pressure
|
|
76
|
+
on a chapter directly surfaces as a stale badge.
|
|
77
|
+
|
|
78
|
+
## Authoring tips
|
|
79
|
+
|
|
80
|
+
- **Start every chapter with Representation.** Even if you know the
|
|
81
|
+
reader has seen the concept before, restate it in the chapter's own
|
|
82
|
+
terms. Assume no prior chapter.
|
|
83
|
+
- **Operation goes second, not last.** Tempting to put examples last;
|
|
84
|
+
the KF structure asks you to argue the object first, then show how
|
|
85
|
+
it behaves.
|
|
86
|
+
- **Evolution is the longest section in early-stage chapters.** When
|
|
87
|
+
the topic is young, the "how did we get here" story is the most
|
|
88
|
+
valuable part of the chapter. As the topic matures, Evolution shrinks
|
|
89
|
+
while Representation and Operation grow.
|
|
90
|
+
|
|
91
|
+
## References
|
|
92
|
+
|
|
93
|
+
- Koller, D., & Friedman, N. (2009). *Probabilistic Graphical Models:
|
|
94
|
+
Principles and Techniques*. MIT Press.
|
|
95
|
+
- The agentic-coding book's `00-design.mdx` explains how the scaffold
|
|
96
|
+
implements these ideas — read it as a worked example.
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Source tiers
|
|
2
|
+
|
|
3
|
+
Every source cited in a book-scaffold-astro book carries a `tier` field
|
|
4
|
+
in `sources/manifest.yaml`. The tier calibrates reader trust at the
|
|
5
|
+
point of use — a citation renders with a tier badge, and the source
|
|
6
|
+
archive page groups entries by tier descending.
|
|
7
|
+
|
|
8
|
+
Four tiers in descending authority. This methodology migrated from the
|
|
9
|
+
predecessor LaTeX book `claude-best-practices`'s `docs/source-hierarchy.md`
|
|
10
|
+
(2025-2026), where it evolved across v2.0 → v2.9.
|
|
11
|
+
|
|
12
|
+
## The four tiers
|
|
13
|
+
|
|
14
|
+
### T1-official
|
|
15
|
+
|
|
16
|
+
Vendor-official documentation or release notes. Highest trust for
|
|
17
|
+
factual claims about the vendor's own tool.
|
|
18
|
+
|
|
19
|
+
Examples:
|
|
20
|
+
- `anthropic.com/docs/...` for claims about Claude Code behavior.
|
|
21
|
+
- `cloud.google.com/gemini-code-assist/...` for Gemini CLI.
|
|
22
|
+
- `platform.openai.com/docs/codex/...` for Codex CLI.
|
|
23
|
+
|
|
24
|
+
Use when the claim is about the vendor's tool's specification — what
|
|
25
|
+
a flag does, what a command name is, what an event payload looks like.
|
|
26
|
+
|
|
27
|
+
### T2-release-notes
|
|
28
|
+
|
|
29
|
+
Release blog posts, changelogs, conference talks from the vendor.
|
|
30
|
+
Trustworthy for intent and availability claims. Slightly less formal
|
|
31
|
+
than T1 docs because release notes describe what the vendor
|
|
32
|
+
*announced*, not necessarily what the shipped artifact behaves like.
|
|
33
|
+
|
|
34
|
+
Examples:
|
|
35
|
+
- `anthropic.com/news/...` for a feature announcement.
|
|
36
|
+
- A YouTube talk from a Google Next session about Gemini CLI.
|
|
37
|
+
- An OpenAI DevDay blog post about Codex CLI release.
|
|
38
|
+
|
|
39
|
+
Use when the claim is about vendor intent, a ship date, or a feature
|
|
40
|
+
preview that may not yet have docs.
|
|
41
|
+
|
|
42
|
+
### T3-practitioner
|
|
43
|
+
|
|
44
|
+
Respected community writing with a durable argument the author has
|
|
45
|
+
defended over time. The author is not the vendor; the writing's
|
|
46
|
+
authority comes from the argument's staying power.
|
|
47
|
+
|
|
48
|
+
Examples:
|
|
49
|
+
- Gwern Branwen on sidenote UX (`gwern.net/sidenote`) — decade-defended
|
|
50
|
+
argument.
|
|
51
|
+
- Edward Tufte's design books — foundational, long-defended typography
|
|
52
|
+
principles.
|
|
53
|
+
- Specific practitioner posts where the author has repeatedly revisited
|
|
54
|
+
and defended the argument.
|
|
55
|
+
|
|
56
|
+
Use when citing a pattern, principle, or methodology that the vendor
|
|
57
|
+
hasn't formally documented but that a serious community author has
|
|
58
|
+
argued over time.
|
|
59
|
+
|
|
60
|
+
### T4-conjecture
|
|
61
|
+
|
|
62
|
+
Blog posts, tweets, unverified claims. Use as pointers to investigate
|
|
63
|
+
rather than as authority.
|
|
64
|
+
|
|
65
|
+
Examples:
|
|
66
|
+
- A tweet claiming a tool does X (without a linked authoritative source).
|
|
67
|
+
- A blog post describing a workaround that worked once.
|
|
68
|
+
- A Reddit thread with consensus but no authoritative confirmation.
|
|
69
|
+
|
|
70
|
+
Use sparingly. If a T4 source is load-bearing for a claim, either
|
|
71
|
+
elevate the claim (find a T1-T3 source) or drop the claim.
|
|
72
|
+
|
|
73
|
+
## Tier is not a judgment of the author
|
|
74
|
+
|
|
75
|
+
A brilliant tweet is T4 until someone does the work to elevate it;
|
|
76
|
+
a bland vendor page is T1 because the vendor is the definitive source
|
|
77
|
+
for their own tool's behavior.
|
|
78
|
+
|
|
79
|
+
This is important. The tier reflects the relationship between the
|
|
80
|
+
source and the claim it supports. A practitioner's blog post *about
|
|
81
|
+
Claude Code's behavior* is T3 (or T4); the same practitioner's blog
|
|
82
|
+
post *about their own methodology for using Claude Code* could be T3
|
|
83
|
+
if the methodology is original and defended.
|
|
84
|
+
|
|
85
|
+
## Re-verification cadence per tier
|
|
86
|
+
|
|
87
|
+
Each tier implies an audit cadence. The scaffold's quarterly audit
|
|
88
|
+
workflow (post-v1.0) operationalizes this:
|
|
89
|
+
|
|
90
|
+
| Tier | Re-verify cadence | Rationale |
|
|
91
|
+
|------|-------------------|-----------|
|
|
92
|
+
| T1-official | On major vendor release | Triggered by release, not calendar |
|
|
93
|
+
| T2-release-notes | Quarterly | Release notes drift as ship dates slip |
|
|
94
|
+
| T3-practitioner | Annually | Authors rarely retract; arguments evolve slowly |
|
|
95
|
+
| T4-conjecture | Before citing | If the claim still matters, verify it; otherwise drop |
|
|
96
|
+
|
|
97
|
+
## How the scaffold uses this
|
|
98
|
+
|
|
99
|
+
- `sources/manifest.yaml` is the source-of-truth. Each entry has a
|
|
100
|
+
`tier` field validated against the `sourceTiers` enum.
|
|
101
|
+
- `<Citation src="slug" />` renders a tier badge at the point of
|
|
102
|
+
citation. Readers calibrate their trust mid-sentence.
|
|
103
|
+
- Appendix D (source archive) groups entries by tier descending
|
|
104
|
+
(T1 → T4). Empty tiers render honest "no entries yet" placeholders.
|
|
105
|
+
- The scaffold does not automate re-verification. That's intentional:
|
|
106
|
+
the human audit is load-bearing; automating it would create a false
|
|
107
|
+
sense of security.
|
|
108
|
+
|
|
109
|
+
## Authoring tips
|
|
110
|
+
|
|
111
|
+
- **Over-cite rather than under-cite.** If a claim rests on external
|
|
112
|
+
evidence, cite it even if you think the evidence is obvious.
|
|
113
|
+
- **Favor T1-T2 for claims about specific tools.** If a T3 practitioner
|
|
114
|
+
post is the best you have for a tool-behavior claim, note the gap;
|
|
115
|
+
the T1 source will likely appear later.
|
|
116
|
+
- **A T4 citation is a research todo.** If you're citing a tweet, ask
|
|
117
|
+
yourself whether the claim belongs in a future-draft note rather than
|
|
118
|
+
a published chapter.
|
|
119
|
+
- **The archive's integrity is the book's integrity.** A source whose
|
|
120
|
+
content shifted beneath a citation silently demotes the chapter that
|
|
121
|
+
cited it to an unknown state.
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Volatility classes
|
|
2
|
+
|
|
3
|
+
Every chapter declares a `volatility` class in its frontmatter. The
|
|
4
|
+
class encodes how fast the chapter's claims are expected to date. The
|
|
5
|
+
freshness badge on the chapter header reads this class and computes
|
|
6
|
+
"fresh" / "verify soon" / "stale" against three thresholds.
|
|
7
|
+
|
|
8
|
+
## The three classes
|
|
9
|
+
|
|
10
|
+
### `stable-principle` — 365-day threshold
|
|
11
|
+
|
|
12
|
+
Claims that trace back to a durable principle or an argument the author
|
|
13
|
+
has defended over many years. These age slowly; re-verify annually.
|
|
14
|
+
|
|
15
|
+
Examples:
|
|
16
|
+
- Chapters on the *shape* of agentic interaction (the session loop,
|
|
17
|
+
context as a finite resource, briefing documents as a stable pattern).
|
|
18
|
+
- Chapters on pedagogy and reading methodology (how to calibrate trust
|
|
19
|
+
against source tier, how to audit your own practice).
|
|
20
|
+
- Chapters whose claims would still be defensible after a major tool
|
|
21
|
+
release because they're not about any specific tool's surface.
|
|
22
|
+
|
|
23
|
+
Freshness bands: fresh < 274d, verify-soon 274-365d, stale > 365d.
|
|
24
|
+
|
|
25
|
+
### `architectural-pattern` — 180-day threshold
|
|
26
|
+
|
|
27
|
+
Claims about cross-tool design patterns that change on major version
|
|
28
|
+
releases but not minor ones. Re-verify every 6 months.
|
|
29
|
+
|
|
30
|
+
Examples:
|
|
31
|
+
- Chapter on subagent delegation (the *pattern* is stable; specific
|
|
32
|
+
interface names and tool signatures can shift on major releases).
|
|
33
|
+
- Chapter on hooks / MCP / plugins (the pattern of "tool extends its
|
|
34
|
+
own behavior via a lifecycle event" is architectural; the specific
|
|
35
|
+
event names and payload shapes are feature-surface).
|
|
36
|
+
- Chapter on automation modes (the *categorization* into interactive /
|
|
37
|
+
headless / scheduled is architectural).
|
|
38
|
+
|
|
39
|
+
Freshness bands: fresh < 135d, verify-soon 135-180d, stale > 180d.
|
|
40
|
+
|
|
41
|
+
### `feature-surface` — 90-day threshold
|
|
42
|
+
|
|
43
|
+
Claims about specific tool features, flags, file paths, command names,
|
|
44
|
+
or configuration schemas. These age fastest; re-verify quarterly.
|
|
45
|
+
|
|
46
|
+
Examples:
|
|
47
|
+
- Tool-specific companion appendices (Claude Code's specific flags,
|
|
48
|
+
Gemini CLI's specific file layout, Codex CLI's specific commands).
|
|
49
|
+
- Chapters on pricing, hook event lists, specific env var names.
|
|
50
|
+
- Any chapter where the example code contains current-release-specific
|
|
51
|
+
API calls.
|
|
52
|
+
|
|
53
|
+
Freshness bands: fresh < 68d, verify-soon 68-90d, stale > 90d.
|
|
54
|
+
|
|
55
|
+
## Choosing the class
|
|
56
|
+
|
|
57
|
+
The dominant rule: **classify by the claim type, not by the topic.**
|
|
58
|
+
|
|
59
|
+
A chapter titled "Subagents" sounds like it should be feature-surface
|
|
60
|
+
(subagent interfaces change), but if the chapter argues the *pattern*
|
|
61
|
+
and uses specific tool syntax only as illustration, it's an
|
|
62
|
+
architectural-pattern chapter. The same chapter could be
|
|
63
|
+
feature-surface if it's a concrete reference document for a specific
|
|
64
|
+
tool's subagent flags.
|
|
65
|
+
|
|
66
|
+
A test: *if this tool ships a major version tomorrow, what changes?*
|
|
67
|
+
- Nothing conceptual → stable-principle.
|
|
68
|
+
- Interfaces but not the pattern → architectural-pattern.
|
|
69
|
+
- Named flags / paths / commands change → feature-surface.
|
|
70
|
+
|
|
71
|
+
## Why three (not two, not five)
|
|
72
|
+
|
|
73
|
+
Three classes encode distinct re-verification cadences:
|
|
74
|
+
- Annual (stable-principle) — corresponds to the book's major-edition
|
|
75
|
+
cycle.
|
|
76
|
+
- Semi-annual (architectural-pattern) — corresponds to tool major
|
|
77
|
+
version release cadence.
|
|
78
|
+
- Quarterly (feature-surface) — corresponds to tool minor release
|
|
79
|
+
cadence.
|
|
80
|
+
|
|
81
|
+
Two classes would collapse annual + semi-annual, hiding cases where a
|
|
82
|
+
chapter is almost-principle-but-not-quite. Four classes would
|
|
83
|
+
over-resolve and create arguments about edge cases. Three is the
|
|
84
|
+
minimum that captures the essential granularity without encouraging
|
|
85
|
+
bikeshedding.
|
|
86
|
+
|
|
87
|
+
## How the scaffold uses this
|
|
88
|
+
|
|
89
|
+
- `src/lib/freshness.ts` maps volatility to threshold. Three status
|
|
90
|
+
bands derived from % of threshold: fresh (<75%), verify-soon (75-100%),
|
|
91
|
+
stale (>100%).
|
|
92
|
+
- `src/components/ChapterHeader.astro` renders a colored badge next to
|
|
93
|
+
the chapter's last-verified date (green / gold / rose).
|
|
94
|
+
- `src/pages/chapters.astro` renders the same badge on every card in
|
|
95
|
+
the chapter index, so readers can assess drift across the whole book
|
|
96
|
+
at a glance.
|
|
97
|
+
|
|
98
|
+
## Authoring tips
|
|
99
|
+
|
|
100
|
+
- **Default to feature-surface on first publication.** You'll almost
|
|
101
|
+
always be wrong about how durable a specific claim is. Letting the
|
|
102
|
+
freshness badge age the claim down to stale is honest; pretending
|
|
103
|
+
it was stable-principle when it wasn't is a drift trap.
|
|
104
|
+
- **Promote to architectural-pattern when the claim survives a major
|
|
105
|
+
release unchanged.** The promotion is evidence, not guess.
|
|
106
|
+
- **Promote to stable-principle only after multiple tools have
|
|
107
|
+
adopted.** Principle-shaped claims should be defended by convergence
|
|
108
|
+
evidence, not by aspiration.
|
|
109
|
+
- **Freshness is not a quality signal.** A stale feature-surface chapter
|
|
110
|
+
isn't wrong; it's old. Re-verify before demoting the chapter.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Recipe 00 — Getting started
|
|
2
|
+
|
|
3
|
+
**Profile**: any (the recipe picks one based on your answer below).
|
|
4
|
+
|
|
5
|
+
**TL;DR**: Pick a profile (`academic` / `tools` / `minimal`). Set `BOOK_PROFILE` in your shell or `.env`. Edit content under `src/content/chapters/`. `npm run dev` to preview.
|
|
6
|
+
|
|
7
|
+
## 1. Choose a profile
|
|
8
|
+
|
|
9
|
+
The scaffold ships three profiles. `BOOK_PROFILE` is read at startup by `astro.config.mjs` and `src/content.config.ts`.
|
|
10
|
+
|
|
11
|
+
| Profile | Use when | Frontmatter schema | Default callouts | Math | Bibliography |
|
|
12
|
+
|---|---|---|---|---|---|
|
|
13
|
+
| `academic` | Textbook, research report, lecture notes | `week`, `part`(enum), `status`(7-state) | NoteBox, Theorem family, ExampleBox … | KaTeX with 36 macros | BibTeX → `src/data/references.json` |
|
|
14
|
+
| `tools` | Comparative practitioner book (multiple tools tracked) | `chapter`, `part`(numeric), `volatility`, `tools_compared`, `sources` | SkillBox, KeyIdea, Convergence, Divergence … | off | YAML manifest at `sources/manifest.yaml` |
|
|
15
|
+
| `minimal` | Single-author manifesto, essays, mixed-form work | falls back to `tools` schema (pick `tools` and ignore the fields you don't use) | tools-family | off | manual references page |
|
|
16
|
+
|
|
17
|
+
Most academic books pick `academic`; most "Agentic Coding" style books pick `tools`. If unsure: pick `minimal` and switch later — schemas are forgiving as long as required fields are set.
|
|
18
|
+
|
|
19
|
+
## 2. Set the profile
|
|
20
|
+
|
|
21
|
+
Either:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Shell-level (one session):
|
|
25
|
+
export BOOK_PROFILE=academic
|
|
26
|
+
npm run dev
|
|
27
|
+
|
|
28
|
+
# Or in package.json scripts:
|
|
29
|
+
"dev": "BOOK_PROFILE=academic astro dev"
|
|
30
|
+
|
|
31
|
+
# Or in .env (recommended for committed defaults):
|
|
32
|
+
echo "BOOK_PROFILE=academic" >> .env
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The profile is read by `import.meta.env.BOOK_PROFILE` at build time. Re-run `npm install` if you change the profile and see stale type errors.
|
|
36
|
+
|
|
37
|
+
## 3. Bootstrap a new book (recommended path)
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
~/.claude/skills/book-scaffold-astro/create-book.sh my-book-name --profile=academic
|
|
41
|
+
cd ~/Claude/my-book-name
|
|
42
|
+
npm install
|
|
43
|
+
npm run dev
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
That creates a GitHub repo from this template, clones to `~/Claude/`, sets `BOOK_PROFILE` in `.env`, and copies the matching `week01-hello-world.mdx` demo chapter. Visit `localhost:4321`.
|
|
47
|
+
|
|
48
|
+
## 4. Customize for your book
|
|
49
|
+
|
|
50
|
+
- **package.json**: set `name`, `description`, `author`, `repository`
|
|
51
|
+
- **wrangler.toml**: replace `name = "your-book-name"` with your project name (hyphens only)
|
|
52
|
+
- **src/components/Sidebar.astro** (top of file): edit `siteTitle` / `siteSubtitle`
|
|
53
|
+
- **bibliography.bib** (academic profile): replace placeholder with your refs
|
|
54
|
+
- **src/content/chapters/week01-hello-world.mdx**: replace with your first chapter (or delete and start over)
|
|
55
|
+
|
|
56
|
+
## 5. Pick a chapter shape
|
|
57
|
+
|
|
58
|
+
The scaffold ships two skeleton templates:
|
|
59
|
+
|
|
60
|
+
- `examples/chapter-template-academic.mdx` — week-based (Overview / Theory / Examples / Reflections / Forward-map)
|
|
61
|
+
- `examples/chapter-template-tools.mdx` — Koller-Friedman (Representation / Operation / Evolution)
|
|
62
|
+
|
|
63
|
+
See recipe 07 for the full rationale. Copy whichever matches your profile to `src/content/chapters/` and start writing.
|
|
64
|
+
|
|
65
|
+
## 6. Deploy
|
|
66
|
+
|
|
67
|
+
When ready, follow `recipes/05-deploy-cloudflare.md` to push to Cloudflare Workers + Static Assets. URL: `https://<book-name>.<account>.workers.dev` after first deploy.
|
|
68
|
+
|
|
69
|
+
## What next
|
|
70
|
+
|
|
71
|
+
- **Adding math**: `recipes/01-add-math.md` (academic profile only)
|
|
72
|
+
- **Adding citations**: `recipes/02-bibliography-pipeline.md`
|
|
73
|
+
- **Adding figures / notebooks**: `recipes/03-asset-pipelines.md`
|
|
74
|
+
- **Using components**: `recipes/04-component-library.md`
|
|
75
|
+
- **Layout tweaks**: `recipes/06-mobile-first-layout.md`
|
|
76
|
+
- **Custom domain**: `recipes/10-custom-domain.md`
|
|
77
|
+
- **All decisions explained**: `recipes/08-decisions-ledger.md`
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Recipe 01 — Add math to your book (KaTeX)
|
|
2
|
+
|
|
3
|
+
**Profile**: academic (gated by `BOOK_PROFILE=academic`)
|
|
4
|
+
|
|
5
|
+
**TL;DR**: Math is wired but disabled by default. Set `BOOK_PROFILE=academic` and the build adds `remark-math` + `rehype-katex` (strict mode) with the SSM macro library at `src/lib/katex-macros.ts`.
|
|
6
|
+
|
|
7
|
+
## How it works
|
|
8
|
+
|
|
9
|
+
The conditional integration lives at the top of `astro.config.mjs`:
|
|
10
|
+
- Reads `process.env.BOOK_PROFILE ?? 'minimal'`
|
|
11
|
+
- For `academic`: dynamically imports `remark-math`, `rehype-katex`, and `ssmMacros`; adds them to the markdown pipeline
|
|
12
|
+
- KaTeX CSS (`katex/dist/katex.min.css`) is always loaded by `Base.astro` — academic books need it; minimal/tools books carry the cost (~60 KB) without rendering math (the CSS is inert without matching DOM)
|
|
13
|
+
|
|
14
|
+
## Enable math in your book
|
|
15
|
+
|
|
16
|
+
1. Set `BOOK_PROFILE=academic` at run time:
|
|
17
|
+
```bash
|
|
18
|
+
BOOK_PROFILE=academic npm run dev # local hot-reload
|
|
19
|
+
BOOK_PROFILE=academic npm run build # production build
|
|
20
|
+
```
|
|
21
|
+
Or persist it in `.env`:
|
|
22
|
+
```
|
|
23
|
+
BOOK_PROFILE=academic
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
2. Author math in MDX with `$...$` (inline) and `$$...$$` (display):
|
|
27
|
+
```mdx
|
|
28
|
+
The continuous SSM $\dot{\statevec} = \statemat \statevec$
|
|
29
|
+
has eigenvalues...
|
|
30
|
+
|
|
31
|
+
$$
|
|
32
|
+
y_t = \outputmat \statevec_t + \feedmat u_t
|
|
33
|
+
$$
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
3. Strict mode is on by default (`strict: 'error'` in `rehypeKatex` options). Unknown macros, malformed expressions, and unsupported AMS environments fail the build with a precise error. This is intentional — catch typos at write-time, not in production.
|
|
37
|
+
|
|
38
|
+
## Macro library
|
|
39
|
+
|
|
40
|
+
`src/lib/katex-macros.ts` defines 36 macros:
|
|
41
|
+
- 20 SSM-specific from the post-transformers academic reference: `\statevec`, `\statemat`, `\inputmat`, `\outputmat`, `\feedmat`, `\stepsize`, `\discA`, `\discB`, `\seqlen`, `\statedim`, `\inputdim`, `\scanop`, `\elemwise`, `\monodromy`, `\floquet`, `\lyapexp`, `\jacobian`, `\ddt`, `\pderiv`, `\spectralradius`
|
|
42
|
+
- 16 general math: `\R`, `\C`, `\N`, `\Z`, `\E`, `\Prob`, `\norm`, `\ip`, `\abs`, `\argmax`, `\argmin`, `\diag`, `\tr`, `\spec`, `\rank`, `\bigO`
|
|
43
|
+
- 1 compatibility alias: `\bm` → `\boldsymbol` (KaTeX doesn't ship `\bm`)
|
|
44
|
+
|
|
45
|
+
To extend for your book, edit `src/lib/katex-macros.ts` and add new entries to the `ssmMacros` object:
|
|
46
|
+
```ts
|
|
47
|
+
export const ssmMacros = {
|
|
48
|
+
// existing macros...
|
|
49
|
+
'\\mybook': '\\mathbb{B}', // 0-arg macro
|
|
50
|
+
'\\myfunc': '\\mathrm{my}(#1)', // 1-arg macro
|
|
51
|
+
};
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Common gotchas
|
|
55
|
+
|
|
56
|
+
- **`\bm{x}` doesn't ship with KaTeX.** The macro library aliases it to `\boldsymbol{x}` (visually identical in stix-two / Computer Modern fonts).
|
|
57
|
+
- **`\psmallmatrix` not supported by KaTeX.** Convert to `\begin{pmatrix} ... \end{pmatrix}` in your MDX source.
|
|
58
|
+
- **Equation auto-numbering across a document is not supported by KaTeX.** Each `$$...$$` block is independent. Use `\tag{N}` for explicit numbering, or a per-chapter remark plugin (deferred; see PROFILES_DESIGN.md §6).
|
|
59
|
+
- **`{,}` (LaTeX thousands separator) breaks MDX** — MDX parses `{...}` as a JSX expression. Use `1,000` not `1{,}000`.
|
|
60
|
+
- **Math inside JSX components needs care.** `<Theorem>$x^2$</Theorem>` works because remark-math runs after MDX parses JSX, but escape any `{` or `}` in arguments.
|
|
61
|
+
|
|
62
|
+
## Canonical files
|
|
63
|
+
|
|
64
|
+
- `astro.config.mjs:14-32` — profile branch + plugin wiring
|
|
65
|
+
- `src/lib/katex-macros.ts` — full macro library (36 entries)
|
|
66
|
+
- `src/layouts/Base.astro:24-30` — KaTeX CSS import
|
|
67
|
+
- `package.json` — `katex ^0.16`, `remark-math ^6`, `rehype-katex ^7` deps
|
|
68
|
+
|
|
69
|
+
## Reference implementation
|
|
70
|
+
|
|
71
|
+
[`~/Claude/post_transformers/guides/web/`](../) at commit `111ba26` (math first wired) through `2eaef5d` (current). The reference book has 6 academic chapters using these macros and exercises every edge case the scaffold supports.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Recipe 02 — Bibliography pipeline (BibTeX → JSON)
|
|
2
|
+
|
|
3
|
+
**Profile**: academic (primarily), but build-bib runs in all profiles and gracefully skips when no `bibliography.bib` is present.
|
|
4
|
+
|
|
5
|
+
**TL;DR**: Author citations in `bibliography.bib` (BibTeX). `npm run dev` or `npm run build` runs `scripts/build-bib.mjs` which emits `src/data/references.json`. Use `<Cite key="bibkey" />` in MDX to render `Author (Year)` links to `/references#bibkey`.
|
|
6
|
+
|
|
7
|
+
## How it works
|
|
8
|
+
|
|
9
|
+
1. **Source**: `bibliography.bib` at scaffold root (overridable via `BOOK_BIB_PATH` env var for books that share a `.bib` with another tree — e.g. a LaTeX sibling).
|
|
10
|
+
2. **Build step**: `scripts/build-bib.mjs` invokes `@citation-js/core` + `@citation-js/plugin-bibtex` to parse the `.bib` and serialize to CSL JSON. Output: `src/data/references.json`, one key per bibkey. Idempotent.
|
|
11
|
+
3. **Pre-hook**: `prebuild` and `predev` both call `npm run build:bib`, so any `npm run dev` / `npm run build` invocation refreshes the JSON.
|
|
12
|
+
4. **Graceful skip**: If `bibliography.bib` is absent (minimal/tools profile, or a fresh scaffold), the script emits `{}` and exits 0. No error.
|
|
13
|
+
5. **Component**: `src/components/Cite.astro` imports `references.json` and renders inline `Author (Year)` styled link. Unknown bibkeys throw a build-time error (same guarantee biber gives the LaTeX build).
|
|
14
|
+
6. **Bibliography page**: `src/pages/references.astro` auto-renders all entries from `references.json`, sorted by surname+year, each with an anchor `id="<bibkey>"` so `<Cite>` links resolve.
|
|
15
|
+
|
|
16
|
+
## Author a citation
|
|
17
|
+
|
|
18
|
+
1. Add a BibTeX entry to `bibliography.bib`:
|
|
19
|
+
```bibtex
|
|
20
|
+
@inproceedings{gu2024mamba,
|
|
21
|
+
author = {Gu, Albert and Dao, Tri},
|
|
22
|
+
title = {Mamba: Linear-Time Sequence Modeling with Selective State Spaces},
|
|
23
|
+
booktitle = {COLM},
|
|
24
|
+
year = {2024},
|
|
25
|
+
note = {arXiv:2312.00752}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
2. Reference in MDX:
|
|
30
|
+
```mdx
|
|
31
|
+
The selective scan <Cite key="gu2024mamba" /> replaces
|
|
32
|
+
the input-independent A matrix with...
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
3. Run the build:
|
|
36
|
+
```bash
|
|
37
|
+
npm run dev # prebuild runs build:bib first, then astro dev
|
|
38
|
+
```
|
|
39
|
+
The Cite component renders `Gu & Dao (2024)` linked to `/references#gu2024mamba`. Optional page-locator: `<Cite key="..." page="42" />`.
|
|
40
|
+
|
|
41
|
+
## Override the `.bib` location
|
|
42
|
+
|
|
43
|
+
If your book stores its `.bib` outside the Astro project root (e.g. shared with a LaTeX sibling at `../shared/references.bib`):
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
BOOK_BIB_PATH=../shared/references.bib npm run build
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Or persist in `.env`:
|
|
50
|
+
```
|
|
51
|
+
BOOK_BIB_PATH=../shared/references.bib
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The script resolves relative paths against `process.cwd()`.
|
|
55
|
+
|
|
56
|
+
## .gitleaks.toml allowlist
|
|
57
|
+
|
|
58
|
+
Gitleaks' generic-api-key entropy heuristic flags bibkeys like `gu2024mamba` as false-positive secrets. The scaffold's `.gitleaks.toml` allowlists:
|
|
59
|
+
- `src/content/chapters/.+\.mdx` (chapter prose using `<Cite key="...">`)
|
|
60
|
+
- `bibliography\.bib` (BibTeX source)
|
|
61
|
+
|
|
62
|
+
For books using `BOOK_BIB_PATH` to point elsewhere, extend the allowlist with the appropriate path pattern in your fork.
|
|
63
|
+
|
|
64
|
+
`src/data/references.json` (the derived artifact) is `.gitignore`d entirely — it's regenerated on every build, and gitignoring it sidesteps gitleaks scanning of high-entropy bibkey arrays.
|
|
65
|
+
|
|
66
|
+
## Common gotchas
|
|
67
|
+
|
|
68
|
+
- **Duplicate bibkeys** cause the script to exit 1 — `@citation-js` silently overwrites earlier entries, which biber would flag. The wrapper script surfaces duplicates so they don't silently lose entries.
|
|
69
|
+
- **Unknown bibkey in `<Cite>` throws at build time** — typos surface as an Astro build error pointing at the offending key.
|
|
70
|
+
- **The `note = {arXiv:...}` convention** in BibTeX entries is detected by `src/pages/references.astro` and surfaced as a direct arXiv link in the bibliography page.
|
|
71
|
+
|
|
72
|
+
## Canonical files
|
|
73
|
+
|
|
74
|
+
- `scripts/build-bib.mjs:35-50` — path resolution + BOOK_BIB_PATH override
|
|
75
|
+
- `src/components/Cite.astro` — author formatting, bibkey lookup
|
|
76
|
+
- `src/pages/references.astro` — sorted bibliography page with anchors
|
|
77
|
+
- `.gitleaks.toml` — bibkey allowlist
|
|
78
|
+
- `package.json` `prebuild` / `predev` — auto-runs build:bib
|
|
79
|
+
|
|
80
|
+
## Reference implementation
|
|
81
|
+
|
|
82
|
+
[`~/Claude/post_transformers/guides/web/`](../) uses this pipeline with a `.bib` shared between biber (LaTeX legacy) and citation-js (active MDX site). 66 entries; see commit `acdc847` for the initial wiring.
|