@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
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __esm = (fn, res) => function __init() {
|
|
4
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
5
|
+
};
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// src/lib/katex-macros.ts
|
|
12
|
+
var katex_macros_exports = {};
|
|
13
|
+
__export(katex_macros_exports, {
|
|
14
|
+
ssmMacros: () => ssmMacros
|
|
15
|
+
});
|
|
16
|
+
var ssmMacros;
|
|
17
|
+
var init_katex_macros = __esm({
|
|
18
|
+
"src/lib/katex-macros.ts"() {
|
|
19
|
+
"use strict";
|
|
20
|
+
ssmMacros = {
|
|
21
|
+
// -----------------------------------------------------------------
|
|
22
|
+
// Compatibility alias: \bm{x} -> \boldsymbol{x}
|
|
23
|
+
// KaTeX does not ship \bm. The LaTeX source uses \bm extensively in
|
|
24
|
+
// ssm-notation.tex for vectors and matrices.
|
|
25
|
+
// -----------------------------------------------------------------
|
|
26
|
+
"\\bm": "\\boldsymbol{#1}",
|
|
27
|
+
// -----------------------------------------------------------------
|
|
28
|
+
// SSM state space variables (ssm-notation.tex:5-13)
|
|
29
|
+
// -----------------------------------------------------------------
|
|
30
|
+
"\\statevec": "\\boldsymbol{h}",
|
|
31
|
+
// state vector h_t
|
|
32
|
+
"\\statemat": "\\boldsymbol{A}",
|
|
33
|
+
// dynamics matrix A
|
|
34
|
+
"\\inputmat": "\\boldsymbol{B}",
|
|
35
|
+
// input matrix B
|
|
36
|
+
"\\outputmat": "\\boldsymbol{C}",
|
|
37
|
+
// output matrix C
|
|
38
|
+
"\\feedmat": "\\boldsymbol{D}",
|
|
39
|
+
// feedthrough matrix D
|
|
40
|
+
"\\stepsize": "\\Delta",
|
|
41
|
+
// discretization step
|
|
42
|
+
"\\discA": "\\bar{\\boldsymbol{A}}",
|
|
43
|
+
// discretized A
|
|
44
|
+
"\\discB": "\\bar{\\boldsymbol{B}}",
|
|
45
|
+
// discretized B
|
|
46
|
+
// -----------------------------------------------------------------
|
|
47
|
+
// Dimensions (ssm-notation.tex:16-18)
|
|
48
|
+
// -----------------------------------------------------------------
|
|
49
|
+
"\\seqlen": "L",
|
|
50
|
+
// sequence length
|
|
51
|
+
"\\statedim": "N",
|
|
52
|
+
// state dimension
|
|
53
|
+
"\\inputdim": "D",
|
|
54
|
+
// input / model dimension
|
|
55
|
+
// -----------------------------------------------------------------
|
|
56
|
+
// Scan operator (ssm-notation.tex:23-24)
|
|
57
|
+
// -----------------------------------------------------------------
|
|
58
|
+
"\\scanop": "\\oplus",
|
|
59
|
+
// associative binary operator for diagonal SSMs
|
|
60
|
+
"\\elemwise": "\\odot",
|
|
61
|
+
// element-wise product
|
|
62
|
+
// -----------------------------------------------------------------
|
|
63
|
+
// Dynamical systems (ssm-notation.tex:27-30)
|
|
64
|
+
// -----------------------------------------------------------------
|
|
65
|
+
"\\monodromy": "\\boldsymbol{Z}",
|
|
66
|
+
// monodromy matrix Z(T)
|
|
67
|
+
"\\floquet": "\\mu",
|
|
68
|
+
// Floquet multiplier
|
|
69
|
+
"\\lyapexp": "\\lambda",
|
|
70
|
+
// Lyapunov exponent
|
|
71
|
+
"\\jacobian": "\\boldsymbol{J}",
|
|
72
|
+
// Jacobian matrix
|
|
73
|
+
// -----------------------------------------------------------------
|
|
74
|
+
// Calculus shortcuts (ssm-notation.tex:33-35)
|
|
75
|
+
// -----------------------------------------------------------------
|
|
76
|
+
"\\ddt": "\\frac{d}{dt}",
|
|
77
|
+
"\\pderiv": "\\frac{\\partial #1}{\\partial #2}",
|
|
78
|
+
// 2 args
|
|
79
|
+
"\\spectralradius": "\\rho",
|
|
80
|
+
// -----------------------------------------------------------------
|
|
81
|
+
// Common sets (preamble:390-393)
|
|
82
|
+
// -----------------------------------------------------------------
|
|
83
|
+
"\\R": "\\mathbb{R}",
|
|
84
|
+
"\\C": "\\mathbb{C}",
|
|
85
|
+
"\\N": "\\mathbb{N}",
|
|
86
|
+
"\\Z": "\\mathbb{Z}",
|
|
87
|
+
// -----------------------------------------------------------------
|
|
88
|
+
// Probability / statistics (preamble:396-397)
|
|
89
|
+
// -----------------------------------------------------------------
|
|
90
|
+
"\\E": "\\mathbb{E}",
|
|
91
|
+
"\\Prob": "\\mathbb{P}",
|
|
92
|
+
// -----------------------------------------------------------------
|
|
93
|
+
// Norms and inner products (preamble:400-402)
|
|
94
|
+
// -----------------------------------------------------------------
|
|
95
|
+
"\\norm": "\\lVert #1 \\rVert",
|
|
96
|
+
"\\ip": "\\langle #1, #2 \\rangle",
|
|
97
|
+
"\\abs": "\\lvert #1 \\rvert",
|
|
98
|
+
// -----------------------------------------------------------------
|
|
99
|
+
// Operators (preamble:405-410)
|
|
100
|
+
// \DeclareMathOperator* -> \operatorname* (with limits below in display)
|
|
101
|
+
// \DeclareMathOperator -> \operatorname
|
|
102
|
+
// -----------------------------------------------------------------
|
|
103
|
+
"\\argmax": "\\operatorname*{arg\\,max}",
|
|
104
|
+
"\\argmin": "\\operatorname*{arg\\,min}",
|
|
105
|
+
"\\diag": "\\operatorname{diag}",
|
|
106
|
+
"\\tr": "\\operatorname{tr}",
|
|
107
|
+
"\\spec": "\\operatorname{spec}",
|
|
108
|
+
"\\rank": "\\operatorname{rank}",
|
|
109
|
+
// -----------------------------------------------------------------
|
|
110
|
+
// Complexity (preamble:413)
|
|
111
|
+
// -----------------------------------------------------------------
|
|
112
|
+
"\\bigO": "\\mathcal{O}(#1)"
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// src/config.ts
|
|
118
|
+
import mdx from "@astrojs/mdx";
|
|
119
|
+
import preact from "@astrojs/preact";
|
|
120
|
+
|
|
121
|
+
// src/types.ts
|
|
122
|
+
var BOOK_PROFILES = ["academic", "tools", "minimal"];
|
|
123
|
+
var BookConfigError = class extends Error {
|
|
124
|
+
constructor(message) {
|
|
125
|
+
super(message);
|
|
126
|
+
this.name = "BookConfigError";
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
function resolveProfile(explicit) {
|
|
130
|
+
const candidate = explicit ?? process.env.BOOK_PROFILE ?? "minimal";
|
|
131
|
+
if (!BOOK_PROFILES.includes(candidate)) {
|
|
132
|
+
throw new BookConfigError(
|
|
133
|
+
`profile must be one of ${BOOK_PROFILES.join(" | ")} (got ${JSON.stringify(candidate)})`
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
if (!explicit && !process.env.BOOK_PROFILE) {
|
|
137
|
+
console.warn("book-scaffold-astro: BOOK_PROFILE not set; falling back to 'minimal'.");
|
|
138
|
+
}
|
|
139
|
+
return candidate;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// src/integration.ts
|
|
143
|
+
import { fileURLToPath } from "url";
|
|
144
|
+
var PACKAGE_NAME = "@brandon_m_behring/book-scaffold-astro";
|
|
145
|
+
var ALWAYS_ON_STYLES = [
|
|
146
|
+
"tokens.css",
|
|
147
|
+
"layout.css",
|
|
148
|
+
"callouts.css",
|
|
149
|
+
"chapter.css",
|
|
150
|
+
"typography.css",
|
|
151
|
+
"print.css"
|
|
152
|
+
];
|
|
153
|
+
var TOOLS_ONLY_STYLES = ["convergence.css", "tool-filter.css"];
|
|
154
|
+
var DEFAULT_ROUTES_ALL = [
|
|
155
|
+
{ pattern: "/chapters", file: "chapters.astro" },
|
|
156
|
+
{ pattern: "/references", file: "references.astro" },
|
|
157
|
+
{ pattern: "/print", file: "print.astro" },
|
|
158
|
+
{ pattern: "/search", file: "search.astro" }
|
|
159
|
+
];
|
|
160
|
+
var DEFAULT_ROUTES_TOOLS = [
|
|
161
|
+
{ pattern: "/convergence", file: "convergence.astro" }
|
|
162
|
+
];
|
|
163
|
+
function resolvePage(file) {
|
|
164
|
+
return fileURLToPath(new URL(`../pages/${file}`, import.meta.url));
|
|
165
|
+
}
|
|
166
|
+
function bookScaffoldIntegration(opts) {
|
|
167
|
+
const { profile, extraStyles = [] } = opts;
|
|
168
|
+
return {
|
|
169
|
+
name: "book-scaffold-astro",
|
|
170
|
+
hooks: {
|
|
171
|
+
"astro:config:setup": ({ injectScript, injectRoute }) => {
|
|
172
|
+
const styles = profile === "tools" ? [...ALWAYS_ON_STYLES, ...TOOLS_ONLY_STYLES, ...extraStyles] : [...ALWAYS_ON_STYLES, ...extraStyles];
|
|
173
|
+
for (const sheet of styles) {
|
|
174
|
+
injectScript("page-ssr", `import '${PACKAGE_NAME}/styles/${sheet}';`);
|
|
175
|
+
}
|
|
176
|
+
const routes = profile === "tools" ? [...DEFAULT_ROUTES_ALL, ...DEFAULT_ROUTES_TOOLS] : [...DEFAULT_ROUTES_ALL];
|
|
177
|
+
for (const route of routes) {
|
|
178
|
+
injectRoute({
|
|
179
|
+
pattern: route.pattern,
|
|
180
|
+
entrypoint: resolvePage(route.file)
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// src/config.ts
|
|
189
|
+
async function defineBookConfig(opts) {
|
|
190
|
+
const profile = resolveProfile(opts.profile);
|
|
191
|
+
const remarkPlugins = [];
|
|
192
|
+
const rehypePlugins = [];
|
|
193
|
+
if (profile === "academic") {
|
|
194
|
+
const { default: remarkMath } = await import("remark-math");
|
|
195
|
+
const { default: rehypeKatex } = await import("rehype-katex");
|
|
196
|
+
const { ssmMacros: ssmMacros2 } = await Promise.resolve().then(() => (init_katex_macros(), katex_macros_exports));
|
|
197
|
+
remarkPlugins.push(remarkMath);
|
|
198
|
+
rehypePlugins.push([
|
|
199
|
+
rehypeKatex,
|
|
200
|
+
{
|
|
201
|
+
// Strict mode: build fails on undefined macros, malformed expressions,
|
|
202
|
+
// unsupported AMS environments. Trades developer pain at write-time
|
|
203
|
+
// for catching errors before deploy.
|
|
204
|
+
strict: "error",
|
|
205
|
+
trust: true,
|
|
206
|
+
macros: ssmMacros2
|
|
207
|
+
}
|
|
208
|
+
]);
|
|
209
|
+
}
|
|
210
|
+
const integrations = [
|
|
211
|
+
mdx(),
|
|
212
|
+
preact(),
|
|
213
|
+
bookScaffoldIntegration({ profile, extraStyles: opts.extraStyles }),
|
|
214
|
+
...opts.extraIntegrations ?? []
|
|
215
|
+
];
|
|
216
|
+
const userMarkdown = opts.markdown ?? {};
|
|
217
|
+
const markdown = {
|
|
218
|
+
shikiConfig: {
|
|
219
|
+
// css-variables mode lets code blocks switch dark/light theme without
|
|
220
|
+
// rebuilding. Tokens map to --astro-code-* CSS vars in tokens.css.
|
|
221
|
+
theme: "css-variables",
|
|
222
|
+
wrap: false,
|
|
223
|
+
...userMarkdown.shikiConfig ?? {}
|
|
224
|
+
},
|
|
225
|
+
remarkPlugins: [...remarkPlugins, ...userMarkdown.remarkPlugins ?? []],
|
|
226
|
+
rehypePlugins: [...rehypePlugins, ...userMarkdown.rehypePlugins ?? []],
|
|
227
|
+
...userMarkdown
|
|
228
|
+
};
|
|
229
|
+
const {
|
|
230
|
+
profile: _profile,
|
|
231
|
+
extraIntegrations: _extraIntegrations,
|
|
232
|
+
extraStyles: _extraStyles,
|
|
233
|
+
markdown: _markdown,
|
|
234
|
+
...rest
|
|
235
|
+
} = opts;
|
|
236
|
+
void _profile;
|
|
237
|
+
void _extraIntegrations;
|
|
238
|
+
void _extraStyles;
|
|
239
|
+
void _markdown;
|
|
240
|
+
const config = {
|
|
241
|
+
...rest,
|
|
242
|
+
integrations,
|
|
243
|
+
markdown
|
|
244
|
+
};
|
|
245
|
+
return config;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// src/schemas.ts
|
|
249
|
+
import { z } from "astro/zod";
|
|
250
|
+
var toolSlugs = [
|
|
251
|
+
"claude-code",
|
|
252
|
+
"gemini-cli",
|
|
253
|
+
"codex-cli",
|
|
254
|
+
"cross-tool"
|
|
255
|
+
];
|
|
256
|
+
var volatilityLevels = [
|
|
257
|
+
"stable-principle",
|
|
258
|
+
"architectural-pattern",
|
|
259
|
+
"feature-surface"
|
|
260
|
+
];
|
|
261
|
+
var sourceTiers = [
|
|
262
|
+
"T1-official",
|
|
263
|
+
"T2-release-notes",
|
|
264
|
+
"T3-practitioner",
|
|
265
|
+
"T4-conjecture"
|
|
266
|
+
];
|
|
267
|
+
var changeKinds = ["added", "removed", "changed", "deprecated"];
|
|
268
|
+
var patternCategories = [
|
|
269
|
+
"safety",
|
|
270
|
+
"scale",
|
|
271
|
+
"context",
|
|
272
|
+
"interaction",
|
|
273
|
+
"extension",
|
|
274
|
+
"other"
|
|
275
|
+
];
|
|
276
|
+
var academicParts = [
|
|
277
|
+
"foundations",
|
|
278
|
+
"ssm-core",
|
|
279
|
+
"beyond-ssm",
|
|
280
|
+
"integration",
|
|
281
|
+
"synthesis"
|
|
282
|
+
];
|
|
283
|
+
var chapterStatus = [
|
|
284
|
+
"implemented",
|
|
285
|
+
"chapter_only",
|
|
286
|
+
"reading_only",
|
|
287
|
+
"prose_only",
|
|
288
|
+
"code_only",
|
|
289
|
+
"scaffolded",
|
|
290
|
+
"planned"
|
|
291
|
+
];
|
|
292
|
+
var academicChapterSchema = z.object({
|
|
293
|
+
week: z.number().int().min(1).max(99),
|
|
294
|
+
part: z.enum(academicParts),
|
|
295
|
+
title: z.string().min(1),
|
|
296
|
+
status: z.enum(chapterStatus),
|
|
297
|
+
roadmap_lines: z.tuple([z.number().int(), z.number().int()]).optional(),
|
|
298
|
+
code_path: z.string().optional(),
|
|
299
|
+
tests_path: z.string().optional(),
|
|
300
|
+
notebook_path: z.string().optional(),
|
|
301
|
+
description: z.string().optional(),
|
|
302
|
+
draft: z.boolean().default(false)
|
|
303
|
+
});
|
|
304
|
+
var toolsChapterSchema = z.object({
|
|
305
|
+
title: z.string().min(1),
|
|
306
|
+
part: z.number().int().min(0).max(10),
|
|
307
|
+
chapter: z.number().int().min(0).max(99),
|
|
308
|
+
volatility: z.enum(volatilityLevels),
|
|
309
|
+
tools_compared: z.array(z.enum(toolSlugs)).min(1),
|
|
310
|
+
last_verified: z.date(),
|
|
311
|
+
sources: z.array(z.string()).default([]),
|
|
312
|
+
description: z.string().optional(),
|
|
313
|
+
draft: z.boolean().default(false),
|
|
314
|
+
updated: z.date().optional()
|
|
315
|
+
});
|
|
316
|
+
var sourcesSchema = z.object({
|
|
317
|
+
url: z.string().url(),
|
|
318
|
+
title: z.string().min(1),
|
|
319
|
+
author: z.string().optional(),
|
|
320
|
+
publish_date: z.date().optional(),
|
|
321
|
+
captured_at: z.date(),
|
|
322
|
+
content_hash: z.string().regex(/^sha256:[a-f0-9]+$/).optional(),
|
|
323
|
+
tier: z.enum(sourceTiers),
|
|
324
|
+
tool: z.enum(toolSlugs),
|
|
325
|
+
perma_cc: z.string().url().nullable().optional(),
|
|
326
|
+
local_cache: z.string().nullable().optional()
|
|
327
|
+
});
|
|
328
|
+
var changelogSchema = z.object({
|
|
329
|
+
tool: z.enum(toolSlugs),
|
|
330
|
+
versions: z.array(
|
|
331
|
+
z.object({
|
|
332
|
+
version: z.string().min(1),
|
|
333
|
+
date: z.date(),
|
|
334
|
+
changes: z.array(
|
|
335
|
+
z.object({
|
|
336
|
+
pattern: z.string(),
|
|
337
|
+
kind: z.enum(changeKinds),
|
|
338
|
+
note: z.string().min(1),
|
|
339
|
+
source_key: z.string().optional()
|
|
340
|
+
})
|
|
341
|
+
).default([])
|
|
342
|
+
})
|
|
343
|
+
).default([])
|
|
344
|
+
});
|
|
345
|
+
var patternsSchema = z.object({
|
|
346
|
+
name: z.string().min(1),
|
|
347
|
+
description: z.string().optional(),
|
|
348
|
+
category: z.enum(patternCategories).optional(),
|
|
349
|
+
convergence_date: z.date().nullable().optional()
|
|
350
|
+
});
|
|
351
|
+
export {
|
|
352
|
+
BOOK_PROFILES,
|
|
353
|
+
BookConfigError,
|
|
354
|
+
academicChapterSchema,
|
|
355
|
+
academicParts,
|
|
356
|
+
bookScaffoldIntegration,
|
|
357
|
+
changeKinds,
|
|
358
|
+
changelogSchema,
|
|
359
|
+
chapterStatus,
|
|
360
|
+
defineBookConfig,
|
|
361
|
+
patternCategories,
|
|
362
|
+
patternsSchema,
|
|
363
|
+
resolveProfile,
|
|
364
|
+
sourceTiers,
|
|
365
|
+
sourcesSchema,
|
|
366
|
+
toolSlugs,
|
|
367
|
+
toolsChapterSchema,
|
|
368
|
+
volatilityLevels
|
|
369
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/lib/katex-macros.ts — KaTeX macro definitions ported from the LaTeX guide.
|
|
3
|
+
*
|
|
4
|
+
* Source files in the LaTeX tree:
|
|
5
|
+
* - guides/shared/ssm-notation.tex (20 SSM-specific macros)
|
|
6
|
+
* - guides/shared/ssm-guide-preamble.sty:387-413 (16 general math macros)
|
|
7
|
+
*
|
|
8
|
+
* Wired into astro.config.mjs via:
|
|
9
|
+
* rehypeKatex({ strict: 'error', macros: ssmMacros, trust: true })
|
|
10
|
+
*
|
|
11
|
+
* KaTeX-specific adaptations:
|
|
12
|
+
* - \bm is not part of KaTeX; aliased to \boldsymbol (visually identical
|
|
13
|
+
* in stix-two / Computer Modern math fonts).
|
|
14
|
+
* - \DeclareMathOperator and \DeclareMathOperator* are translated to
|
|
15
|
+
* \operatorname / \operatorname* respectively.
|
|
16
|
+
* - \psmallmatrix is an environment in amsmath, not a macro. KaTeX
|
|
17
|
+
* macros operate at command level; substitution happens in the
|
|
18
|
+
* converter script (latex-to-mdx.mjs in Phase 2.7) — search for
|
|
19
|
+
* \begin{psmallmatrix} and replace with \begin{pmatrix}.
|
|
20
|
+
*
|
|
21
|
+
* Equation numbering is handled by a separate remark plugin (deferred to
|
|
22
|
+
* a follow-up session per plan Phase 2.1 Task #9).
|
|
23
|
+
*/
|
|
24
|
+
declare const ssmMacros: Record<string, string>;
|
|
25
|
+
|
|
26
|
+
export { ssmMacros };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// src/lib/katex-macros.ts
|
|
2
|
+
var ssmMacros = {
|
|
3
|
+
// -----------------------------------------------------------------
|
|
4
|
+
// Compatibility alias: \bm{x} -> \boldsymbol{x}
|
|
5
|
+
// KaTeX does not ship \bm. The LaTeX source uses \bm extensively in
|
|
6
|
+
// ssm-notation.tex for vectors and matrices.
|
|
7
|
+
// -----------------------------------------------------------------
|
|
8
|
+
"\\bm": "\\boldsymbol{#1}",
|
|
9
|
+
// -----------------------------------------------------------------
|
|
10
|
+
// SSM state space variables (ssm-notation.tex:5-13)
|
|
11
|
+
// -----------------------------------------------------------------
|
|
12
|
+
"\\statevec": "\\boldsymbol{h}",
|
|
13
|
+
// state vector h_t
|
|
14
|
+
"\\statemat": "\\boldsymbol{A}",
|
|
15
|
+
// dynamics matrix A
|
|
16
|
+
"\\inputmat": "\\boldsymbol{B}",
|
|
17
|
+
// input matrix B
|
|
18
|
+
"\\outputmat": "\\boldsymbol{C}",
|
|
19
|
+
// output matrix C
|
|
20
|
+
"\\feedmat": "\\boldsymbol{D}",
|
|
21
|
+
// feedthrough matrix D
|
|
22
|
+
"\\stepsize": "\\Delta",
|
|
23
|
+
// discretization step
|
|
24
|
+
"\\discA": "\\bar{\\boldsymbol{A}}",
|
|
25
|
+
// discretized A
|
|
26
|
+
"\\discB": "\\bar{\\boldsymbol{B}}",
|
|
27
|
+
// discretized B
|
|
28
|
+
// -----------------------------------------------------------------
|
|
29
|
+
// Dimensions (ssm-notation.tex:16-18)
|
|
30
|
+
// -----------------------------------------------------------------
|
|
31
|
+
"\\seqlen": "L",
|
|
32
|
+
// sequence length
|
|
33
|
+
"\\statedim": "N",
|
|
34
|
+
// state dimension
|
|
35
|
+
"\\inputdim": "D",
|
|
36
|
+
// input / model dimension
|
|
37
|
+
// -----------------------------------------------------------------
|
|
38
|
+
// Scan operator (ssm-notation.tex:23-24)
|
|
39
|
+
// -----------------------------------------------------------------
|
|
40
|
+
"\\scanop": "\\oplus",
|
|
41
|
+
// associative binary operator for diagonal SSMs
|
|
42
|
+
"\\elemwise": "\\odot",
|
|
43
|
+
// element-wise product
|
|
44
|
+
// -----------------------------------------------------------------
|
|
45
|
+
// Dynamical systems (ssm-notation.tex:27-30)
|
|
46
|
+
// -----------------------------------------------------------------
|
|
47
|
+
"\\monodromy": "\\boldsymbol{Z}",
|
|
48
|
+
// monodromy matrix Z(T)
|
|
49
|
+
"\\floquet": "\\mu",
|
|
50
|
+
// Floquet multiplier
|
|
51
|
+
"\\lyapexp": "\\lambda",
|
|
52
|
+
// Lyapunov exponent
|
|
53
|
+
"\\jacobian": "\\boldsymbol{J}",
|
|
54
|
+
// Jacobian matrix
|
|
55
|
+
// -----------------------------------------------------------------
|
|
56
|
+
// Calculus shortcuts (ssm-notation.tex:33-35)
|
|
57
|
+
// -----------------------------------------------------------------
|
|
58
|
+
"\\ddt": "\\frac{d}{dt}",
|
|
59
|
+
"\\pderiv": "\\frac{\\partial #1}{\\partial #2}",
|
|
60
|
+
// 2 args
|
|
61
|
+
"\\spectralradius": "\\rho",
|
|
62
|
+
// -----------------------------------------------------------------
|
|
63
|
+
// Common sets (preamble:390-393)
|
|
64
|
+
// -----------------------------------------------------------------
|
|
65
|
+
"\\R": "\\mathbb{R}",
|
|
66
|
+
"\\C": "\\mathbb{C}",
|
|
67
|
+
"\\N": "\\mathbb{N}",
|
|
68
|
+
"\\Z": "\\mathbb{Z}",
|
|
69
|
+
// -----------------------------------------------------------------
|
|
70
|
+
// Probability / statistics (preamble:396-397)
|
|
71
|
+
// -----------------------------------------------------------------
|
|
72
|
+
"\\E": "\\mathbb{E}",
|
|
73
|
+
"\\Prob": "\\mathbb{P}",
|
|
74
|
+
// -----------------------------------------------------------------
|
|
75
|
+
// Norms and inner products (preamble:400-402)
|
|
76
|
+
// -----------------------------------------------------------------
|
|
77
|
+
"\\norm": "\\lVert #1 \\rVert",
|
|
78
|
+
"\\ip": "\\langle #1, #2 \\rangle",
|
|
79
|
+
"\\abs": "\\lvert #1 \\rvert",
|
|
80
|
+
// -----------------------------------------------------------------
|
|
81
|
+
// Operators (preamble:405-410)
|
|
82
|
+
// \DeclareMathOperator* -> \operatorname* (with limits below in display)
|
|
83
|
+
// \DeclareMathOperator -> \operatorname
|
|
84
|
+
// -----------------------------------------------------------------
|
|
85
|
+
"\\argmax": "\\operatorname*{arg\\,max}",
|
|
86
|
+
"\\argmin": "\\operatorname*{arg\\,min}",
|
|
87
|
+
"\\diag": "\\operatorname{diag}",
|
|
88
|
+
"\\tr": "\\operatorname{tr}",
|
|
89
|
+
"\\spec": "\\operatorname{spec}",
|
|
90
|
+
"\\rank": "\\operatorname{rank}",
|
|
91
|
+
// -----------------------------------------------------------------
|
|
92
|
+
// Complexity (preamble:413)
|
|
93
|
+
// -----------------------------------------------------------------
|
|
94
|
+
"\\bigO": "\\mathcal{O}(#1)"
|
|
95
|
+
};
|
|
96
|
+
export {
|
|
97
|
+
ssmMacros
|
|
98
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { e as BookSchemasOptions } from './types-Cz-pwE1N.js';
|
|
2
|
+
import 'astro';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns the package's default content collections. Closed shape per Q5;
|
|
6
|
+
* consumer extends via object spread and Zod `.extend()` (see PACKAGE_DESIGN.md §5).
|
|
7
|
+
*/
|
|
8
|
+
declare function defineBookSchemas(opts?: BookSchemasOptions): {
|
|
9
|
+
collections: {
|
|
10
|
+
chapters: unknown;
|
|
11
|
+
sources: unknown;
|
|
12
|
+
changelog: unknown;
|
|
13
|
+
patterns: unknown;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { defineBookSchemas };
|
package/dist/schemas.mjs
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// src/schemas-entry.ts
|
|
2
|
+
import { defineCollection } from "astro:content";
|
|
3
|
+
import { glob, file } from "astro/loaders";
|
|
4
|
+
|
|
5
|
+
// src/types.ts
|
|
6
|
+
var BOOK_PROFILES = ["academic", "tools", "minimal"];
|
|
7
|
+
var BookConfigError = class extends Error {
|
|
8
|
+
constructor(message) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = "BookConfigError";
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
function resolveProfile(explicit) {
|
|
14
|
+
const candidate = explicit ?? process.env.BOOK_PROFILE ?? "minimal";
|
|
15
|
+
if (!BOOK_PROFILES.includes(candidate)) {
|
|
16
|
+
throw new BookConfigError(
|
|
17
|
+
`profile must be one of ${BOOK_PROFILES.join(" | ")} (got ${JSON.stringify(candidate)})`
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
if (!explicit && !process.env.BOOK_PROFILE) {
|
|
21
|
+
console.warn("book-scaffold-astro: BOOK_PROFILE not set; falling back to 'minimal'.");
|
|
22
|
+
}
|
|
23
|
+
return candidate;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// src/schemas.ts
|
|
27
|
+
import { z } from "astro/zod";
|
|
28
|
+
var toolSlugs = [
|
|
29
|
+
"claude-code",
|
|
30
|
+
"gemini-cli",
|
|
31
|
+
"codex-cli",
|
|
32
|
+
"cross-tool"
|
|
33
|
+
];
|
|
34
|
+
var volatilityLevels = [
|
|
35
|
+
"stable-principle",
|
|
36
|
+
"architectural-pattern",
|
|
37
|
+
"feature-surface"
|
|
38
|
+
];
|
|
39
|
+
var sourceTiers = [
|
|
40
|
+
"T1-official",
|
|
41
|
+
"T2-release-notes",
|
|
42
|
+
"T3-practitioner",
|
|
43
|
+
"T4-conjecture"
|
|
44
|
+
];
|
|
45
|
+
var changeKinds = ["added", "removed", "changed", "deprecated"];
|
|
46
|
+
var patternCategories = [
|
|
47
|
+
"safety",
|
|
48
|
+
"scale",
|
|
49
|
+
"context",
|
|
50
|
+
"interaction",
|
|
51
|
+
"extension",
|
|
52
|
+
"other"
|
|
53
|
+
];
|
|
54
|
+
var academicParts = [
|
|
55
|
+
"foundations",
|
|
56
|
+
"ssm-core",
|
|
57
|
+
"beyond-ssm",
|
|
58
|
+
"integration",
|
|
59
|
+
"synthesis"
|
|
60
|
+
];
|
|
61
|
+
var chapterStatus = [
|
|
62
|
+
"implemented",
|
|
63
|
+
"chapter_only",
|
|
64
|
+
"reading_only",
|
|
65
|
+
"prose_only",
|
|
66
|
+
"code_only",
|
|
67
|
+
"scaffolded",
|
|
68
|
+
"planned"
|
|
69
|
+
];
|
|
70
|
+
var academicChapterSchema = z.object({
|
|
71
|
+
week: z.number().int().min(1).max(99),
|
|
72
|
+
part: z.enum(academicParts),
|
|
73
|
+
title: z.string().min(1),
|
|
74
|
+
status: z.enum(chapterStatus),
|
|
75
|
+
roadmap_lines: z.tuple([z.number().int(), z.number().int()]).optional(),
|
|
76
|
+
code_path: z.string().optional(),
|
|
77
|
+
tests_path: z.string().optional(),
|
|
78
|
+
notebook_path: z.string().optional(),
|
|
79
|
+
description: z.string().optional(),
|
|
80
|
+
draft: z.boolean().default(false)
|
|
81
|
+
});
|
|
82
|
+
var toolsChapterSchema = z.object({
|
|
83
|
+
title: z.string().min(1),
|
|
84
|
+
part: z.number().int().min(0).max(10),
|
|
85
|
+
chapter: z.number().int().min(0).max(99),
|
|
86
|
+
volatility: z.enum(volatilityLevels),
|
|
87
|
+
tools_compared: z.array(z.enum(toolSlugs)).min(1),
|
|
88
|
+
last_verified: z.date(),
|
|
89
|
+
sources: z.array(z.string()).default([]),
|
|
90
|
+
description: z.string().optional(),
|
|
91
|
+
draft: z.boolean().default(false),
|
|
92
|
+
updated: z.date().optional()
|
|
93
|
+
});
|
|
94
|
+
var sourcesSchema = z.object({
|
|
95
|
+
url: z.string().url(),
|
|
96
|
+
title: z.string().min(1),
|
|
97
|
+
author: z.string().optional(),
|
|
98
|
+
publish_date: z.date().optional(),
|
|
99
|
+
captured_at: z.date(),
|
|
100
|
+
content_hash: z.string().regex(/^sha256:[a-f0-9]+$/).optional(),
|
|
101
|
+
tier: z.enum(sourceTiers),
|
|
102
|
+
tool: z.enum(toolSlugs),
|
|
103
|
+
perma_cc: z.string().url().nullable().optional(),
|
|
104
|
+
local_cache: z.string().nullable().optional()
|
|
105
|
+
});
|
|
106
|
+
var changelogSchema = z.object({
|
|
107
|
+
tool: z.enum(toolSlugs),
|
|
108
|
+
versions: z.array(
|
|
109
|
+
z.object({
|
|
110
|
+
version: z.string().min(1),
|
|
111
|
+
date: z.date(),
|
|
112
|
+
changes: z.array(
|
|
113
|
+
z.object({
|
|
114
|
+
pattern: z.string(),
|
|
115
|
+
kind: z.enum(changeKinds),
|
|
116
|
+
note: z.string().min(1),
|
|
117
|
+
source_key: z.string().optional()
|
|
118
|
+
})
|
|
119
|
+
).default([])
|
|
120
|
+
})
|
|
121
|
+
).default([])
|
|
122
|
+
});
|
|
123
|
+
var patternsSchema = z.object({
|
|
124
|
+
name: z.string().min(1),
|
|
125
|
+
description: z.string().optional(),
|
|
126
|
+
category: z.enum(patternCategories).optional(),
|
|
127
|
+
convergence_date: z.date().nullable().optional()
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// src/schemas-entry.ts
|
|
131
|
+
function defineBookSchemas(opts = {}) {
|
|
132
|
+
const profile = resolveProfile(opts.profile);
|
|
133
|
+
const chaptersBase = opts.chaptersBase ?? "./src/content/chapters";
|
|
134
|
+
const chapters = defineCollection({
|
|
135
|
+
loader: glob({
|
|
136
|
+
// Exclude underscore-prefixed files (standard "hidden" convention).
|
|
137
|
+
pattern: ["**/*.{md,mdx}", "!**/_*"],
|
|
138
|
+
base: chaptersBase
|
|
139
|
+
}),
|
|
140
|
+
schema: profile === "academic" ? academicChapterSchema : toolsChapterSchema
|
|
141
|
+
});
|
|
142
|
+
const sources = defineCollection({
|
|
143
|
+
loader: file("sources/manifest.yaml"),
|
|
144
|
+
schema: sourcesSchema
|
|
145
|
+
});
|
|
146
|
+
const changelog = defineCollection({
|
|
147
|
+
loader: glob({ pattern: "*.yaml", base: "./changelog/tools" }),
|
|
148
|
+
schema: changelogSchema
|
|
149
|
+
});
|
|
150
|
+
const patterns = defineCollection({
|
|
151
|
+
loader: file("changelog/patterns.yaml"),
|
|
152
|
+
schema: patternsSchema
|
|
153
|
+
});
|
|
154
|
+
return {
|
|
155
|
+
collections: { chapters, sources, changelog, patterns }
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
export {
|
|
159
|
+
defineBookSchemas
|
|
160
|
+
};
|