@mvarble/mesearch-workflow 0.0.0-stage → 0.2.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.
Files changed (165) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +109 -2
  3. package/agents/reference/authoring.md +127 -0
  4. package/agents/reference/workflow.md +106 -0
  5. package/agents/skills/wf-abandon/SKILL.md +16 -0
  6. package/agents/skills/wf-approve/SKILL.md +23 -0
  7. package/agents/skills/wf-build/SKILL.md +41 -0
  8. package/agents/skills/wf-plan/SKILL.md +47 -0
  9. package/agents/skills/wf-publish/SKILL.md +41 -0
  10. package/agents/skills/wf-reopen/SKILL.md +20 -0
  11. package/agents/skills/wf-resume/SKILL.md +16 -0
  12. package/agents/skills/wf-start/SKILL.md +25 -0
  13. package/agents/skills/wf-status/SKILL.md +12 -0
  14. package/agents/skills/wf-writeup/SKILL.md +58 -0
  15. package/app/ambient.d.ts +71 -0
  16. package/app/lib/components/CopyCode.svelte +24 -0
  17. package/app/lib/components/DocumentMap.svelte +38 -0
  18. package/app/lib/components/DocumentPage.svelte +184 -0
  19. package/app/lib/components/Icon.svelte +35 -0
  20. package/app/lib/components/ImageFigure.svelte +213 -0
  21. package/app/lib/components/LinkList.svelte +46 -0
  22. package/app/lib/components/ModelGraph.svelte +169 -0
  23. package/app/lib/components/OpenEntry.svelte +35 -0
  24. package/app/lib/components/PageList.svelte +35 -0
  25. package/app/lib/components/PrevNext.svelte +24 -0
  26. package/app/lib/components/Proof.svelte +12 -0
  27. package/app/lib/components/Shell.svelte +55 -0
  28. package/app/lib/components/Sidebar.svelte +77 -0
  29. package/app/lib/components/StageRail.svelte +30 -0
  30. package/app/lib/components/Statement.svelte +41 -0
  31. package/app/lib/components/Tex.svelte +25 -0
  32. package/app/lib/components/ThemeToggle.svelte +17 -0
  33. package/app/lib/components/Timeline.svelte +31 -0
  34. package/app/lib/components/Toc.svelte +41 -0
  35. package/app/lib/components/TopBar.svelte +55 -0
  36. package/app/lib/components/TrackCard.svelte +20 -0
  37. package/app/lib/documents.ts +52 -0
  38. package/app/lib/graph/describe.ts +29 -0
  39. package/app/lib/graph/geometry.ts +296 -0
  40. package/app/lib/graph/spec.ts +158 -0
  41. package/app/lib/kit.ts +11 -0
  42. package/app/lib/load.ts +12 -0
  43. package/app/lib/map.ts +6 -0
  44. package/app/lib/nav.ts +91 -0
  45. package/app/lib/questions.ts +33 -0
  46. package/app/lib/server/document.ts +117 -0
  47. package/app/lib/server/map.ts +41 -0
  48. package/app/lib/server/markdown.ts +134 -0
  49. package/app/lib/server/open.ts +35 -0
  50. package/app/lib/server/repo.ts +6 -0
  51. package/app/lib/server/specs.ts +26 -0
  52. package/app/lib/server/title.ts +9 -0
  53. package/app/lib/state/persisted.svelte.ts +40 -0
  54. package/app/lib/state/theme.svelte.ts +24 -0
  55. package/app/lib/tex.ts +99 -0
  56. package/app/params/slug.ts +5 -0
  57. package/app/params/track.ts +5 -0
  58. package/app/routes/+layout.ts +2 -0
  59. package/app/routes/[...key].md/+server.ts +19 -0
  60. package/app/routes/[track=track]/+page.server.ts +14 -0
  61. package/app/routes/[track=track]/+page.svelte +24 -0
  62. package/app/routes/[track=track]/[slug=slug]/+page.server.ts +9 -0
  63. package/app/routes/[track=track]/[slug=slug]/+page.svelte +7 -0
  64. package/app/routes/[track=track]/[slug=slug]/+page.ts +4 -0
  65. package/app/routes/archive/+page.server.ts +18 -0
  66. package/app/routes/archive/+page.svelte +44 -0
  67. package/app/routes/archive/[entry=slug]/+page.server.ts +9 -0
  68. package/app/routes/archive/[entry=slug]/+page.svelte +7 -0
  69. package/app/routes/archive/[entry=slug]/+page.ts +4 -0
  70. package/app/routes/archive/[entry=slug]/[name=slug]/+page.server.ts +14 -0
  71. package/app/routes/archive/[entry=slug]/[name=slug]/+page.svelte +7 -0
  72. package/app/routes/archive/[entry=slug]/[name=slug]/+page.ts +4 -0
  73. package/app/routes/llms-full.txt/+server.ts +17 -0
  74. package/app/routes/llms.txt/+server.ts +50 -0
  75. package/app/routes/math/+page.server.ts +21 -0
  76. package/app/routes/math/+page.svelte +56 -0
  77. package/app/routes/math/[slug=slug]/+page.server.ts +8 -0
  78. package/app/routes/math/[slug=slug]/+page.svelte +7 -0
  79. package/app/routes/math/[slug=slug]/+page.ts +4 -0
  80. package/app/styles/base.css +98 -0
  81. package/app/styles/code.css +83 -0
  82. package/app/styles/index.css +17 -0
  83. package/app/styles/katex.css +14 -0
  84. package/app/styles/layout.css +545 -0
  85. package/app/styles/text.css +96 -0
  86. package/app/styles/tokens/dimensions.css +31 -0
  87. package/app/styles/tokens/typography.css +33 -0
  88. package/app/styles/tokens.css +2 -0
  89. package/app/styles/utils/archive.css +339 -0
  90. package/app/styles/utils/buttons.css +28 -0
  91. package/app/styles/utils/callouts.css +41 -0
  92. package/app/styles/utils/cards.css +95 -0
  93. package/app/styles/utils/graph.css +186 -0
  94. package/app/styles/utils/map.css +45 -0
  95. package/app/styles/utils/tables.css +25 -0
  96. package/dist/cli.d.ts +2 -0
  97. package/dist/cli.js +88 -0
  98. package/dist/cli.js.map +1 -0
  99. package/dist/engine/cli.d.ts +12 -0
  100. package/dist/engine/cli.js +744 -0
  101. package/dist/engine/cli.js.map +1 -0
  102. package/dist/engine/config.d.ts +40 -0
  103. package/dist/engine/config.js +16 -0
  104. package/dist/engine/config.js.map +1 -0
  105. package/dist/engine/lib.d.ts +108 -0
  106. package/dist/engine/lib.js +375 -0
  107. package/dist/engine/lib.js.map +1 -0
  108. package/dist/engine/main.d.ts +1 -0
  109. package/dist/engine/main.js +45 -0
  110. package/dist/engine/main.js.map +1 -0
  111. package/dist/index.d.ts +4 -0
  112. package/dist/index.js +3 -0
  113. package/dist/index.js.map +1 -0
  114. package/dist/site/hooks.d.ts +27 -0
  115. package/dist/site/hooks.js +2 -0
  116. package/dist/site/hooks.js.map +1 -0
  117. package/dist/site/index.d.ts +1 -0
  118. package/dist/site/index.js +2 -0
  119. package/dist/site/index.js.map +1 -0
  120. package/dist/site/preset/index.d.ts +15 -0
  121. package/dist/site/preset/index.js +556 -0
  122. package/dist/site/preset/index.js.map +1 -0
  123. package/dist/site/preset/runtime.d.ts +42 -0
  124. package/dist/site/preset/runtime.js +99 -0
  125. package/dist/site/preset/runtime.js.map +1 -0
  126. package/dist/site/preset/types.d.ts +87 -0
  127. package/dist/site/preset/types.js +2 -0
  128. package/dist/site/preset/types.js.map +1 -0
  129. package/dist/site/vite.d.ts +14 -0
  130. package/dist/site/vite.js +202 -0
  131. package/dist/site/vite.js.map +1 -0
  132. package/dist/sync/index.d.ts +17 -0
  133. package/dist/sync/index.js +175 -0
  134. package/dist/sync/index.js.map +1 -0
  135. package/dist/sync/init.d.ts +7 -0
  136. package/dist/sync/init.js +62 -0
  137. package/dist/sync/init.js.map +1 -0
  138. package/dist/sync/render.d.ts +3 -0
  139. package/dist/sync/render.js +118 -0
  140. package/dist/sync/render.js.map +1 -0
  141. package/dist/sync/site.d.ts +3 -0
  142. package/dist/sync/site.js +58 -0
  143. package/dist/sync/site.js.map +1 -0
  144. package/package.json +78 -3
  145. package/templates/.agents/reference/authoring.md +11 -0
  146. package/templates/.agents/reference/stages/README.md +4 -0
  147. package/templates/AGENTS.md +36 -0
  148. package/templates/site/content/landing.md +5 -0
  149. package/templates/site/katex.config.ts +5 -0
  150. package/templates/site/package.json +22 -0
  151. package/templates/site/src/app.d.ts +8 -0
  152. package/templates/site/src/app.html +23 -0
  153. package/templates/site/src/lib/components/Logo.svelte +12 -0
  154. package/templates/site/src/lib/site.ts +39 -0
  155. package/templates/site/src/routes/+layout.server.ts +3 -0
  156. package/templates/site/src/routes/+layout.svelte +11 -0
  157. package/templates/site/src/routes/+page.server.ts +3 -0
  158. package/templates/site/src/routes/+page.svelte +34 -0
  159. package/templates/site/src/routes/+page.ts +7 -0
  160. package/templates/site/src/styles/index.css +4 -0
  161. package/templates/site/src/styles/tokens/colors.css +107 -0
  162. package/templates/site/static/favicon.svg +1 -0
  163. package/templates/site/tsconfig.json +20 -0
  164. package/templates/site/vite.config.ts +4 -0
  165. package/templates/workflow.config.ts +40 -0
@@ -0,0 +1,169 @@
1
+ <script lang="ts">
2
+ import { layoutGraph, type TextLayout } from '../graph/geometry';
3
+ import {
4
+ edgeKindClasses,
5
+ nodeKindClasses,
6
+ type EdgeSpec,
7
+ type GraphSpec,
8
+ type NodeSpec,
9
+ } from '../graph/spec';
10
+ import { renderMixed } from '../tex';
11
+
12
+ // Renders a hand-placed graph figure (see `$lib/graph/spec.ts`) as SVG, with a caption and a
13
+ // legend of the node and edge kinds it uses, named and styled as the figure defines them. All
14
+ // geometry is computed in `$lib/graph/geometry.ts`; this component only writes it out.
15
+ //
16
+ // Text is not drawn in the SVG. It sits in an HTML layer over it, so that labels can hold
17
+ // KaTeX: HTML inside an SVG would need `<foreignObject>`, whose box must be sized in advance
18
+ // (impossible without measuring, and so without JavaScript), and WebKit misplaces the
19
+ // `position: relative` spans KaTeX is built from inside a scaled one. Each label is placed
20
+ // by percentage, and its font size tracks the figure's width through container-query units,
21
+ // so the layer scales exactly with the drawing, all in CSS.
22
+
23
+ let { spec }: { spec: GraphSpec } = $props();
24
+
25
+ const layout = $derived(layoutGraph(spec));
26
+ const id = $props.id();
27
+ const text = (source: string) => renderMixed(source, spec.katexMacros);
28
+
29
+ const nodeClass = (node: NodeSpec) =>
30
+ ['graph-node', nodeKindClasses(spec.nodeKinds[node.kind]), node.class]
31
+ .filter(Boolean)
32
+ .join(' ');
33
+
34
+ const edgeClass = (edge: EdgeSpec) =>
35
+ [
36
+ 'graph-edge',
37
+ edgeKindClasses(edge.kind === undefined ? undefined : spec.edgeKinds?.[edge.kind]),
38
+ edge.muted && 'graph-muted',
39
+ edge.class,
40
+ ]
41
+ .filter(Boolean)
42
+ .join(' ');
43
+
44
+ // Positions a label: its point as a percentage of the viewport, then a translation that puts
45
+ // the requested part of its box on that point.
46
+ const SHIFT_X = { start: '0%', middle: '-50%', end: '-100%' };
47
+ const SHIFT_Y = { hanging: '0%', middle: '-50%', auto: '-100%' };
48
+ const place = (t: TextLayout) =>
49
+ `left: ${(t.x / layout.width) * 100}%; top: ${(t.y / layout.height) * 100}%; ` +
50
+ `transform: translate(${SHIFT_X[t.anchor]}, ${SHIFT_Y[t.baseline]});`;
51
+ const centered = (x: number, y: number) =>
52
+ place({ x, y, anchor: 'middle', baseline: 'middle' });
53
+
54
+ // The legend lists the kinds this figure uses, in the order the figure declares them.
55
+ const legend = $derived.by(() => {
56
+ const nodeKinds = new Set(spec.nodes.map((n) => n.kind));
57
+ const edgeKinds = new Set(spec.edges.map((e) => e.kind));
58
+ return {
59
+ nodes: Object.entries(spec.nodeKinds).filter(([key]) => nodeKinds.has(key)),
60
+ edges: Object.entries(spec.edgeKinds ?? {}).filter(([key]) => edgeKinds.has(key)),
61
+ };
62
+ });
63
+ </script>
64
+
65
+ <figure class="model-graph">
66
+ <div
67
+ class="graph-canvas"
68
+ style:max-width="{layout.width}px"
69
+ style:--graph-width={layout.width}
70
+ style:--graph-font={layout.fontSize}
71
+ >
72
+ <svg viewBox="0 0 {layout.width} {layout.height}" role="img" aria-labelledby="{id}-title">
73
+ <title id="{id}-title">{spec.title}</title>
74
+
75
+ {#each layout.edges as edge, i (i)}
76
+ <g class={edgeClass(edge.spec)} style={edge.spec.style}>
77
+ <path d={edge.d} />
78
+ {#each edge.arrows as points, j (j)}
79
+ <polygon {points} />
80
+ {/each}
81
+ </g>
82
+ {/each}
83
+
84
+ {#each layout.nodes as node (node.spec.id)}
85
+ <g
86
+ class={nodeClass(node.spec)}
87
+ class:graph-muted={node.spec.muted}
88
+ style={node.spec.style}
89
+ >
90
+ {#if node.spec.title}<title>{node.spec.title}</title>{/if}
91
+ {#if node.shape == 'square'}
92
+ <rect
93
+ x={node.cx - node.r}
94
+ y={node.cy - node.r}
95
+ width={2 * node.r}
96
+ height={2 * node.r}
97
+ rx="3"
98
+ />
99
+ {:else}
100
+ <circle cx={node.cx} cy={node.cy} r={node.r} />
101
+ {/if}
102
+ </g>
103
+ {/each}
104
+ </svg>
105
+
106
+ <div class="graph-labels">
107
+ {#each layout.edges as edge, i (i)}
108
+ {#if edge.label}
109
+ <span
110
+ class="edge-label {edgeClass(edge.spec)}"
111
+ style={centered(edge.label.x, edge.label.y)}
112
+ >{@html text(edge.spec.label!)}</span
113
+ >
114
+ {/if}
115
+ {/each}
116
+ {#each layout.nodes as node (node.spec.id)}
117
+ {#if node.spec.label}
118
+ <span
119
+ class="node-label"
120
+ class:graph-muted={node.spec.muted}
121
+ style={centered(node.cx, node.cy)}>{@html text(node.spec.label)}</span
122
+ >
123
+ {/if}
124
+ {#if node.annotation}
125
+ <span
126
+ class="node-annotation"
127
+ class:graph-muted={node.spec.muted}
128
+ style={place(node.annotation)}>{@html text(node.spec.annotation!)}</span
129
+ >
130
+ {/if}
131
+ {/each}
132
+ </div>
133
+ </div>
134
+
135
+ {#if spec.legend ?? true}
136
+ <ul class="graph-legend" aria-label="Legend">
137
+ {#each legend.nodes as [key, kind] (key)}
138
+ <li>
139
+ <svg viewBox="-9 -9 18 18" width="14" height="14" aria-hidden="true">
140
+ <g class="graph-node {nodeKindClasses(kind)}">
141
+ {#if kind.shape == 'square'}
142
+ <rect x="-7" y="-7" width="14" height="14" rx="2" />
143
+ {:else}
144
+ <circle r="7" />
145
+ {/if}
146
+ </g>
147
+ </svg>
148
+ <span>{@html text(kind.name)}</span>
149
+ </li>
150
+ {/each}
151
+ {#each legend.edges as [key, kind] (key)}
152
+ <li>
153
+ <svg viewBox="0 0 28 10" width="28" height="10" aria-hidden="true">
154
+ <g class="graph-edge {edgeKindClasses(kind)}">
155
+ <path d="M 1 5 L 20 5" />
156
+ <polygon points="27,5 19,1.5 19,8.5" />
157
+ </g>
158
+ </svg>
159
+ <span>{@html text(kind.name)}</span>
160
+ </li>
161
+ {/each}
162
+ </ul>
163
+ {/if}
164
+
165
+ <figcaption>
166
+ <strong>{spec.title}.</strong>
167
+ {#if spec.caption}{@html text(spec.caption)}{/if}
168
+ </figcaption>
169
+ </figure>
@@ -0,0 +1,35 @@
1
+ <script lang="ts">
2
+ import type { OpenEntryData } from '../server/open';
3
+ import { KIND_LABELS, STAGE_COMMANDS } from '$site';
4
+ import StageRail from './StageRail.svelte';
5
+
6
+ let { entry }: { entry: OpenEntryData } = $props();
7
+ </script>
8
+
9
+ <article class="open-entry">
10
+ <header>
11
+ <a href={entry.link.href}>{entry.link.title}</a>
12
+ <span class="chip">{KIND_LABELS[entry.kind] ?? entry.kind}</span>
13
+ </header>
14
+ <StageRail kind={entry.kind} stage={entry.stage} approvals={entry.approvals} />
15
+ {#if entry.questions.length}
16
+ <p class="open-count">
17
+ {entry.questions.length == 1
18
+ ? '1 open question keeps'
19
+ : `${entry.questions.length} open questions keep`} this stage from being approved:
20
+ </p>
21
+ <ol class="open-questions">
22
+ {#each entry.questions as question, i (i)}
23
+ <li><a href={question.href}>{question.title}</a></li>
24
+ {/each}
25
+ </ol>
26
+ <p class="muted">
27
+ Answer in the conversation with <code>{STAGE_COMMANDS[entry.stage]}</code>.
28
+ </p>
29
+ {:else}
30
+ <p class="muted">
31
+ Nothing is open. Keep working with <code>{STAGE_COMMANDS[entry.stage]}</code>, or give
32
+ <code>/wf-approve</code> to move on.
33
+ </p>
34
+ {/if}
35
+ </article>
@@ -0,0 +1,35 @@
1
+ <script lang="ts">
2
+ import type { DocumentLink } from '../documents';
3
+ import { STATUS_LABELS } from '$site';
4
+ import { renderMixed } from '../tex';
5
+
6
+ // The documents of a section, one row each.
7
+ let {
8
+ links,
9
+ numbered = false,
10
+ start = 1,
11
+ empty,
12
+ }: { links: DocumentLink[]; numbered?: boolean; start?: number; empty: string } = $props();
13
+ </script>
14
+
15
+ {#if links.length}
16
+ <ol class="page-list" class:numbered {start}>
17
+ {#each links as link, i (link.key)}
18
+ <li>
19
+ <a href={link.href}>
20
+ {#if numbered}<span class="index">{String(start + i).padStart(2, '0')}</span
21
+ >{/if}
22
+ <span class="title"
23
+ >{@html renderMixed(link.title)}{#if link.status}
24
+ <span class="chip status-{link.status}"
25
+ >{STATUS_LABELS[link.status]}</span
26
+ >{/if}</span
27
+ >
28
+ <span class="summary">{@html renderMixed(link.summary)}</span>
29
+ </a>
30
+ </li>
31
+ {/each}
32
+ </ol>
33
+ {:else}
34
+ <p class="muted">{empty}</p>
35
+ {/if}
@@ -0,0 +1,24 @@
1
+ <script lang="ts">
2
+ import type { DocumentLink } from '../documents';
3
+ import { renderMixed } from '../tex';
4
+ import Icon from './Icon.svelte';
5
+
6
+ let { prev, next }: { prev?: DocumentLink; next?: DocumentLink } = $props();
7
+ </script>
8
+
9
+ {#if prev || next}
10
+ <nav class="prev-next" aria-label="Previous and next pages">
11
+ {#if prev}
12
+ <a class="prev" href={prev.href}>
13
+ <span class="label"><Icon name="arrowLeft" size={14} /> Previous</span>
14
+ <span class="title">{@html renderMixed(prev.title)}</span>
15
+ </a>
16
+ {/if}
17
+ {#if next}
18
+ <a class="next" href={next.href}>
19
+ <span class="label">Next <Icon name="arrowRight" size={14} /></span>
20
+ <span class="title">{@html renderMixed(next.title)}</span>
21
+ </a>
22
+ {/if}
23
+ </nav>
24
+ {/if}
@@ -0,0 +1,12 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+
4
+ // A proof, ending in ∎.
5
+ let { children, title = 'Proof' }: { children: Snippet; title?: string } = $props();
6
+ </script>
7
+
8
+ <div class="proof">
9
+ <span class="proof-heading">{title}.</span>
10
+ {@render children()}
11
+ <span class="qed" aria-label="End of proof">∎</span>
12
+ </div>
@@ -0,0 +1,55 @@
1
+ <!--
2
+ The frame every page is drawn in: the top bar, the navigation beside the content (but on the
3
+ home page), and the footer. A site's `+layout.svelte` imports its stylesheet and renders its
4
+ pages in this, giving what its `<head>` adds, such as a link preview's image, as `head`.
5
+ -->
6
+ <script lang="ts">
7
+ import type { Snippet } from 'svelte';
8
+
9
+ import { asset, resolve } from '$app/paths';
10
+ import { page } from '$app/state';
11
+ import { SITE } from '$site';
12
+ import Sidebar from './Sidebar.svelte';
13
+ import TopBar from './TopBar.svelte';
14
+
15
+ let {
16
+ origin = '',
17
+ head,
18
+ children,
19
+ }: { origin?: string; head?: Snippet; children: Snippet } = $props();
20
+ let menuOpen = $state(false);
21
+
22
+ const landing = $derived(page.route.id === '/');
23
+ </script>
24
+
25
+ <svelte:head>
26
+ <link rel="alternate" type="text/plain" title="llms.txt" href={resolve('/llms.txt')} />
27
+ <link rel="icon" href={asset('/favicon.svg')} />
28
+ <meta property="og:site_name" content={SITE.name} />
29
+ <meta property="og:type" content="website" />
30
+ {#if origin}<meta property="og:url" content={origin + page.url.pathname} />{/if}
31
+ {@render head?.()}
32
+ </svelte:head>
33
+
34
+ <a class="skip-link" href="#content">Skip to content</a>
35
+ <TopBar bind:menuOpen showMenu={!landing} />
36
+
37
+ <div class="shell" class:landing>
38
+ {#if !landing}
39
+ <Sidebar bind:open={menuOpen} />
40
+ {/if}
41
+ <main id="content">
42
+ {@render children()}
43
+ </main>
44
+ </div>
45
+
46
+ <footer class="site-footer">
47
+ <p>
48
+ {SITE.name} is developed at
49
+ <a href={SITE.repo} rel="external">{SITE.repo.replace('https://', '')}</a>.
50
+ </p>
51
+ <p>
52
+ For language models: <a href={resolve('/llms.txt')}>llms.txt</a> (index) ·
53
+ <a href={resolve('/llms-full.txt')}>llms-full.txt</a> (every page, as Markdown).
54
+ </p>
55
+ </footer>
@@ -0,0 +1,77 @@
1
+ <script lang="ts">
2
+ import { page } from '$app/state';
3
+ import type { NavItem, NavSection } from '../nav';
4
+
5
+ let { open = $bindable(false) }: { open?: boolean } = $props();
6
+
7
+ const sections = $derived(page.data.nav as NavSection[]);
8
+ // Links are written without a trailing slash and pages are served with one, so the two are
9
+ // compared without it.
10
+ const bare = (path: string) => path.replace(/\/+$/, '');
11
+ const here = $derived(bare(page.url.pathname));
12
+ const under = (href: string) => here === bare(href) || here.startsWith(bare(href) + '/');
13
+
14
+ // A section folded away lists its items only while the reader is in it.
15
+ const shown = (section: NavSection) => !section.folded || under(section.href);
16
+ // An item with children unfolds while the reader is on one of them, or under its `within`.
17
+ const unfolded = (item: NavItem) =>
18
+ !!item.children &&
19
+ (item.children.some((child) => here === bare(child.href)) ||
20
+ (item.within !== undefined && under(item.within)));
21
+ </script>
22
+
23
+ {#snippet link(item: NavItem, current: boolean)}
24
+ <a href={item.href} aria-current={current ? 'page' : undefined} onclick={() => (open = false)}
25
+ >{#if item.code}<code>{item.title}</code
26
+ >{:else}{item.title}{/if}{#if item.status && item.status != 'done'}
27
+ <span class="status-dot status-{item.status}" title={item.status}></span>{/if}</a
28
+ >
29
+ {/snippet}
30
+
31
+ <nav id="sidebar" class="sidebar" class:open aria-label="Documentation">
32
+ {#each sections as section (section.id)}
33
+ <details open={section.items.length > 0 && shown(section)}>
34
+ <summary>
35
+ <a href={section.href}>{section.title}</a>
36
+ </summary>
37
+ {#if section.items.length && shown(section)}
38
+ <ol>
39
+ {#each section.items as item (item.key)}
40
+ {@const unfold = unfolded(item)}
41
+ <li
42
+ class:nav-sub={item.sub}
43
+ class:nav-group={item.children}
44
+ class:unfolded={unfold}
45
+ >
46
+ <!-- A group's own link is the current page only when it is a document
47
+ of its own (an entry), not when it stands for its first child. -->
48
+ {@render link(
49
+ item,
50
+ here === bare(item.href) &&
51
+ !item.children?.some((child) => bare(child.href) === here),
52
+ )}
53
+ {#if unfold && item.children}
54
+ <ol>
55
+ {#each item.children as child (child.key)}
56
+ <li class="nav-child">
57
+ {@render link(child, here === bare(child.href))}
58
+ </li>
59
+ {/each}
60
+ </ol>
61
+ {/if}
62
+ </li>
63
+ {/each}
64
+ </ol>
65
+ {/if}
66
+ </details>
67
+ {/each}
68
+ </nav>
69
+
70
+ {#if open}
71
+ <button
72
+ class="sidebar-scrim"
73
+ type="button"
74
+ aria-label="Close navigation"
75
+ onclick={() => (open = false)}
76
+ ></button>
77
+ {/if}
@@ -0,0 +1,30 @@
1
+ <script lang="ts">
2
+ import { STAGES, STAGE_LABELS } from '$site';
3
+
4
+ // The stages of an entry's kind, and how far it has come along them.
5
+ let {
6
+ kind,
7
+ stage,
8
+ approvals = {},
9
+ }: {
10
+ kind: string;
11
+ stage: string;
12
+ approvals?: Record<string, { stale?: boolean }>;
13
+ } = $props();
14
+
15
+ const stateOf = (name: string) => {
16
+ if (name == stage) return 'current';
17
+ if (stage == 'done') return 'approved';
18
+ const approval = approvals[name];
19
+ if (!approval) return 'ahead';
20
+ return approval.stale ? 'reopened' : 'approved';
21
+ };
22
+ </script>
23
+
24
+ <ol class="stage-rail" aria-label="Stages">
25
+ {#each STAGES[kind] ?? [] as name (name)}
26
+ <li class="stage-{stateOf(name)}" aria-current={name == stage ? 'step' : undefined}>
27
+ {STAGE_LABELS[name] ?? name}
28
+ </li>
29
+ {/each}
30
+ </ol>
@@ -0,0 +1,41 @@
1
+ <!--
2
+ What a document imports to show a statement --- a theorem, a definition --- written as a
3
+ document of its own, beside it:
4
+
5
+ import Statement from './Statement.svelte';
6
+ import * as whitening from './statements/whitening.md';
7
+
8
+ <Statement {...whitening} />
9
+
10
+ The content database numbers it along with the document's equations, and `[%full](statement:x)`
11
+ refers to it as "Lemma 2".
12
+ -->
13
+ <script lang="ts">
14
+ import type { Component } from 'svelte';
15
+ import type { StatementInjection } from '@mvarble/mesearch-cms/runtime';
16
+
17
+ let {
18
+ default: Body,
19
+ cms,
20
+ noLabel = false,
21
+ }: { default: Component; cms: StatementInjection; noLabel?: boolean } = $props();
22
+
23
+ // Claims are set in italics, as in a textbook; definitions and remarks stay upright.
24
+ const UPRIGHT = /^(definition|remark|example|notation|note|exercise|assumption|problem)s?$/i;
25
+ const upright = $derived(UPRIGHT.test(cms.kind.trim()));
26
+ const name = $derived(
27
+ cms.kind
28
+ .split(' ')
29
+ .map((word) => word.slice(0, 1).toUpperCase() + word.slice(1))
30
+ .join(' '),
31
+ );
32
+ </script>
33
+
34
+ <div class="statement" class:upright id={cms.id ?? cms.slug}>
35
+ {#if !noLabel}
36
+ <span class="statement-heading"
37
+ >{name}&nbsp;{cms.label}{#if cms.title}<span class="statement-title">({cms.title})</span
38
+ >{/if}.</span
39
+ >
40
+ {/if}<Body />
41
+ </div>
@@ -0,0 +1,25 @@
1
+ <script lang="ts">
2
+ import { renderTex, type Macros } from '../tex';
3
+
4
+ // KaTeX, rendered while the page is prerendered, so it displays without JavaScript.
5
+ //
6
+ // <Tex src={String.raw`\int_0^1 f(x)\,dx`} />
7
+ // <Tex display src={String.raw`\calI(\theta) = \E[s s^\top]`} />
8
+ //
9
+ // `String.raw` keeps backslashes as written. In a `.svx` page, `$…$` and `$$…$$` do the same job
10
+ // with less ceremony; this component is for Svelte markup and for props.
11
+
12
+ let {
13
+ src,
14
+ display = false,
15
+ macros,
16
+ }: { src: string; display?: boolean; macros?: Macros } = $props();
17
+
18
+ const html = $derived(renderTex(src, { display, macros }));
19
+ </script>
20
+
21
+ {#if display}
22
+ <div class="tex-display">{@html html}</div>
23
+ {:else}
24
+ <span class="tex">{@html html}</span>
25
+ {/if}
@@ -0,0 +1,17 @@
1
+ <script lang="ts">
2
+ import { theme } from '../state/theme.svelte.ts';
3
+ import Icon from './Icon.svelte';
4
+
5
+ $effect(() => {
6
+ document.documentElement.classList.toggle('dark', theme.current === 'dark');
7
+ });
8
+ </script>
9
+
10
+ <button
11
+ class="icon-button"
12
+ type="button"
13
+ aria-label="Switch to {theme.current === 'dark' ? 'light' : 'dark'} theme"
14
+ onclick={() => (theme.current = theme.current === 'dark' ? 'light' : 'dark')}
15
+ >
16
+ <Icon name={theme.current === 'dark' ? 'sun' : 'moon'} />
17
+ </button>
@@ -0,0 +1,31 @@
1
+ <script lang="ts">
2
+ import type { WorkflowEvent } from '../documents';
3
+
4
+ // An entry's stage record, as `bin/wf` wrote it: when each stage was approved, and when and
5
+ // why the entry went back to an earlier one.
6
+ let { events }: { events: WorkflowEvent[] } = $props();
7
+
8
+ const VERBS: Record<string, string> = {
9
+ start: 'Started at',
10
+ approve: 'Approved',
11
+ reopen: 'Reopened',
12
+ abandon: 'Set aside at',
13
+ resume: 'Taken up again at',
14
+ amend: 'Amended',
15
+ };
16
+ </script>
17
+
18
+ <ol class="timeline">
19
+ {#each events as event, i (i)}
20
+ <li class="event-{event.action}">
21
+ <time datetime={event.date}>{event.date}</time>
22
+ <span class="what"
23
+ >{VERBS[event.action] ?? event.action}
24
+ <b>{event.action == 'amend' ? (event.document ?? event.stage) : event.stage}</b>
25
+ {#if event.action == 'amend' && event.by}by {event.by}{/if}</span
26
+ >
27
+ {#if event.commit}<code class="commit">{event.commit}</code>{/if}
28
+ {#if event.reason}<span class="reason">{event.reason}</span>{/if}
29
+ </li>
30
+ {/each}
31
+ </ol>
@@ -0,0 +1,41 @@
1
+ <script lang="ts">
2
+ import type { Heading } from '../documents';
3
+ import { renderMixed } from '../tex';
4
+
5
+ let { headings }: { headings: Heading[] } = $props();
6
+
7
+ // Scroll-spy: the active entry is the last heading above the top third of the viewport.
8
+ let active = $state<string | undefined>();
9
+
10
+ $effect(() => {
11
+ const elements = headings
12
+ .map((h) => document.getElementById(h.slug))
13
+ .filter((el): el is HTMLElement => el !== null);
14
+ const update = () => {
15
+ const line = window.innerHeight / 3;
16
+ let current = elements[0]?.id;
17
+ for (const el of elements) {
18
+ if (el.getBoundingClientRect().top <= line) current = el.id;
19
+ }
20
+ active = current;
21
+ };
22
+ update();
23
+ window.addEventListener('scroll', update, { passive: true });
24
+ return () => window.removeEventListener('scroll', update);
25
+ });
26
+ </script>
27
+
28
+ {#if headings.length}
29
+ <nav class="toc" aria-label="On this page">
30
+ <p class="toc-title">On this page</p>
31
+ <ol>
32
+ {#each headings as h (h.slug)}
33
+ <li class="depth-{h.depth}">
34
+ <a href="#{h.slug}" aria-current={active === h.slug ? 'location' : undefined}
35
+ >{@html renderMixed(h.title)}</a
36
+ >
37
+ </li>
38
+ {/each}
39
+ </ol>
40
+ </nav>
41
+ {/if}
@@ -0,0 +1,55 @@
1
+ <script lang="ts">
2
+ import { resolve } from '$app/paths';
3
+ import { page } from '$app/state';
4
+ import { Logo, SITE } from '$site';
5
+ import type { NavSection } from '../nav';
6
+ import Icon from './Icon.svelte';
7
+ import ThemeToggle from './ThemeToggle.svelte';
8
+
9
+ let {
10
+ menuOpen = $bindable(false),
11
+ showMenu = true,
12
+ }: { menuOpen?: boolean; showMenu?: boolean } = $props();
13
+
14
+ // Every section but "Start here", which the home page leads to.
15
+ const sections = $derived((page.data.nav as NavSection[]).filter((s) => s.id != 'start'));
16
+ const current = $derived(page.url.pathname);
17
+ </script>
18
+
19
+ <header class="topbar">
20
+ {#if showMenu}
21
+ <button
22
+ class="icon-button menu-button"
23
+ type="button"
24
+ aria-label={menuOpen ? 'Close navigation' : 'Open navigation'}
25
+ aria-expanded={menuOpen}
26
+ aria-controls="sidebar"
27
+ onclick={() => (menuOpen = !menuOpen)}
28
+ >
29
+ <Icon name={menuOpen ? 'close' : 'menu'} />
30
+ </button>
31
+ {/if}
32
+
33
+ <a class="wordmark" href={resolve('/')}>
34
+ <Logo variant="icon" />
35
+ <span>{SITE.name}</span>
36
+ <span class="version">v{SITE.version}</span>
37
+ </a>
38
+
39
+ <nav class="track-nav" aria-label="Sections">
40
+ {#each sections as section (section.id)}
41
+ <a
42
+ href={section.href}
43
+ aria-current={current.startsWith(section.href) ? 'page' : undefined}
44
+ >{section.short}</a
45
+ >
46
+ {/each}
47
+ </nav>
48
+
49
+ <div class="topbar-actions">
50
+ <a class="icon-button" href={SITE.repo} rel="external" aria-label="Source on GitHub">
51
+ <Icon name="github" />
52
+ </a>
53
+ <ThemeToggle />
54
+ </div>
55
+ </header>