@mvarble/mesearch-workflow 0.0.0-stage → 0.1.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 +142 -0
  4. package/agents/reference/workflow.md +118 -0
  5. package/agents/skills/wf-abandon/SKILL.md +18 -0
  6. package/agents/skills/wf-approve/SKILL.md +24 -0
  7. package/agents/skills/wf-build/SKILL.md +45 -0
  8. package/agents/skills/wf-plan/SKILL.md +49 -0
  9. package/agents/skills/wf-publish/SKILL.md +42 -0
  10. package/agents/skills/wf-reopen/SKILL.md +22 -0
  11. package/agents/skills/wf-resume/SKILL.md +16 -0
  12. package/agents/skills/wf-start/SKILL.md +27 -0
  13. package/agents/skills/wf-status/SKILL.md +15 -0
  14. package/agents/skills/wf-writeup/SKILL.md +61 -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 +50 -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 +19 -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 +59 -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 +526 -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 +115 -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 +12 -0
  146. package/templates/.agents/reference/stages/README.md +5 -0
  147. package/templates/AGENTS.md +42 -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,27 @@
1
+ ---
2
+ name: wf-start
3
+ description: Open a new entry ({{kinds-list}}) on the current branch of {{project}}'s development workflow. Use only when the user invokes /wf-start.
4
+ disable-model-invocation: true
5
+ argument-hint: '<slug> <{{kinds}}> [what it is about] [revises <slug>]'
6
+ ---
7
+
8
+ # /wf-start: open an entry
9
+
10
+ ## Steps
11
+
12
+ 1. Work out the slug (lowercase words joined by hyphens, named after the idea), the kind, a title,
13
+ and any entry it revises from what the user wrote. Ask if the kind is unclear. The kinds, as
14
+ `bin/wf kinds` lists them:
15
+
16
+ {{kinds-describe}}
17
+
18
+ 2. If the current branch is `main`, make a branch for the entry first (`git switch -c <slug>`),
19
+ unless your environment names the branch to work on.
20
+ 3. Run `bin/wf start <slug> --kind <kind> --title "<Title>"`, adding `--revises <slug>,...` when
21
+ it changes the story of finished entries. If it refuses, tell the user what it said and stop.
22
+ 4. Replace the `[!TODO]` in `{{content}}/archive/<slug>/index.md` with a paragraph saying what the
23
+ entry sets out to do and why, from what the user said. Ask for what is missing rather than
24
+ inventing it.
25
+ 5. Commit the entry folder and `.workflow/active` ("Start <slug>: <title>").
26
+ 6. Reply with the first stage's skill (`bin/wf status` names it). Do not start that stage until
27
+ the user invokes it.
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: wf-status
3
+ description: Report where the active entry of {{project}}'s development workflow stands and what comes next. Use only when the user invokes /wf-status.
4
+ disable-model-invocation: true
5
+ argument-hint: ''
6
+ ---
7
+
8
+ # /wf-status
9
+
10
+ 1. Run `bin/wf status`, and `bin/wf check` to see whether the branch keeps the rules.
11
+ 2. Summarize: the entry and its kind, the stage, what has been approved and when (from
12
+ `workflow.json`), the plan's progress if it has one, any problem `check` found, and the
13
+ command that comes next.
14
+ 3. With no active entry, list the entries in the archive with their stages, and say how one is
15
+ started.
@@ -0,0 +1,61 @@
1
+ ---
2
+ name: wf-writeup
3
+ description: Draft or revise the writeup of the active decision entry, the argument for a position {{project}} takes, in {{project}}'s development workflow. Use only when the user invokes /wf-writeup.
4
+ disable-model-invocation: true
5
+ argument-hint: '[what to write, answer or change]'
6
+ ---
7
+
8
+ # /wf-writeup: a decision
9
+
10
+ A decision is a position the project takes, argued in prose until the user and the agent agree on
11
+ it. It is then published into the pages that follow from it. Several small positions that stand or
12
+ fall together may share one entry, each with its own `## ` section and its own `> [!TODO]`.
13
+
14
+ ## Before anything
15
+
16
+ Run `bin/wf status --expect writeup`. If it fails, stop and tell the user what it said.
17
+
18
+ Read `.agents/reference/mesearch/workflow.md`, `.agents/reference/mesearch/authoring.md` and
19
+ `.agents/reference/authoring.md` once per session, `.agents/reference/stages/writeup.md` if the
20
+ project has it, the entry's `index.md`, and the current draft (`bin/wf path`), if any.
21
+
22
+ ## Working with the user
23
+
24
+ A decision is reached by asking. When the user asks for a decision to be worked out, interrogate
25
+ before writing: what they want, what was built or tried before, what the facts it rests on
26
+ actually say, and why. Offer alternatives where the user's choice looks weak, where an existing
27
+ tool already does this, or where the goals and the design disagree, and say plainly which you
28
+ would choose. Record the questions still open as `> [!TODO]` callouts in the draft, and work
29
+ through them with the user.
30
+
31
+ Each invocation is one revision of `{{content}}/archive/<slug>/writeup.md`:
32
+
33
+ ```markdown
34
+ ---
35
+ summary: <one sentence: the position taken>
36
+ ---
37
+
38
+ ## Context
39
+
40
+ What prompted the decision: the problem, the constraints, what came before.
41
+
42
+ ## Decision
43
+
44
+ The position, stated plainly, then argued: what it means for the project, with code only to show
45
+ that. Say which facts it rests on.
46
+
47
+ ## Consequences
48
+
49
+ What it makes easy, what it makes hard, and what it costs.
50
+
51
+ ## Alternatives
52
+
53
+ What else was considered, and why it lost.
54
+ ```
55
+
56
+ A long decision (a charter, or several positions) may use its own sections instead, as long as it
57
+ argues rather than describes. After a reopening, keep a `## Revisions` section saying what changed
58
+ and why.
59
+
60
+ Commit each revision. When nothing is open, reply that `/wf-approve` moves to publishing. Never
61
+ approve yourself.
@@ -0,0 +1,71 @@
1
+ // The modules the app reads from the project, which `docsSite()` serves. A site's `src/app.d.ts`
2
+ // takes these with `/// <reference types="@mvarble/mesearch-workflow/ambient" />`.
3
+
4
+ declare module '$site' {
5
+ import type { Component } from 'svelte';
6
+
7
+ interface Section {
8
+ id: string;
9
+ title: string;
10
+ short: string;
11
+ blurb: string;
12
+ }
13
+
14
+ export const SITE: {
15
+ name: string;
16
+ tagline: string;
17
+ description: string;
18
+ repo: string;
19
+ branch: string;
20
+ version: string;
21
+ };
22
+ export const TRACKS: Section[];
23
+ export const MATH: Section;
24
+ export const MATH_PARTS: { id: string; title: string; blurb: string }[];
25
+ /** `about`, when given, is the paragraph the archive's page opens with. */
26
+ export const ARCHIVE: Section & { about?: string };
27
+ export const DOCUMENTS: readonly { name: string; title: string }[];
28
+ export const KIND_LABELS: Record<string, string>;
29
+ export const STATUS_LABELS: Record<string, string>;
30
+ export const STAGES: Record<string, string[]>;
31
+ export const STAGE_LABELS: Record<string, string>;
32
+ export const STAGE_COMMANDS: Record<string, string>;
33
+ /** `about` follows "Every document below links to its Markdown source." in `llms.txt`. */
34
+ export const LLMS: { about: string };
35
+ /** `mathBefore`: the track the math notes are listed before; after the last by default. */
36
+ export const NAV: { mathBefore?: string };
37
+ export const THEME_KEY: string;
38
+ export const katex: { macros?: Record<string, string>; [option: string]: unknown };
39
+ export const Logo: Component<{ variant: 'icon' | 'lockup' }>;
40
+ }
41
+
42
+ declare module '$site/server' {
43
+ import type { SiteHooks } from '@mvarble/mesearch-workflow';
44
+ export const hooks: SiteHooks;
45
+ }
46
+
47
+ // The content database, which `docsSite()` serves under these names.
48
+ declare module '$cms' {
49
+ import type { SiteCms } from '@mvarble/mesearch-workflow/preset';
50
+ export const cms: SiteCms;
51
+ }
52
+
53
+ declare module '$cms/loaders' {
54
+ import type { Component } from 'svelte';
55
+ const loaders: Record<string, () => Promise<{ default: Component }>>;
56
+ export default loaders;
57
+ }
58
+
59
+ declare module '*.svx' {
60
+ import type { Component } from 'svelte';
61
+ const component: Component;
62
+ export default component;
63
+ export const metadata: Record<string, unknown>;
64
+ }
65
+
66
+ declare module '*.md' {
67
+ import type { Component } from 'svelte';
68
+ const component: Component;
69
+ export default component;
70
+ export const metadata: Record<string, unknown>;
71
+ }
@@ -0,0 +1,24 @@
1
+ <script lang="ts">
2
+ // Adds a copy button to every highlighted block inside `root`. The blocks are static HTML from
3
+ // mdsvex, so the buttons are attached after mount rather than rendered by a component.
4
+ let { root }: { root: HTMLElement | undefined } = $props();
5
+
6
+ $effect(() => {
7
+ if (!root) return;
8
+ const buttons: HTMLButtonElement[] = [];
9
+ for (const pre of root.querySelectorAll<HTMLPreElement>('pre.shiki')) {
10
+ const button = document.createElement('button');
11
+ button.type = 'button';
12
+ button.className = 'copy-button';
13
+ button.textContent = 'Copy';
14
+ button.addEventListener('click', async () => {
15
+ await navigator.clipboard.writeText(pre.innerText);
16
+ button.textContent = 'Copied';
17
+ setTimeout(() => (button.textContent = 'Copy'), 1500);
18
+ });
19
+ pre.parentElement?.insertBefore(button, pre);
20
+ buttons.push(button);
21
+ }
22
+ return () => buttons.forEach((b) => b.remove());
23
+ });
24
+ </script>
@@ -0,0 +1,38 @@
1
+ <script lang="ts">
2
+ import {
3
+ Graph,
4
+ type GraphLegend,
5
+ type GraphLink,
6
+ type GraphNode,
7
+ type IndexEntry,
8
+ } from '@mvarble/mesearch-ui';
9
+
10
+ import { MAP_TUNING } from '../map';
11
+
12
+ // mesearch's map of documents: math notes, and the archive documents that build on them, shown
13
+ // on the Mathematics and Archive pages alike. Solid arrows run from what a document builds on
14
+ // to the document; dashed lines join documents that link to each other. Its colours come from
15
+ // skoro's tokens (`styles/utils/map.css`).
16
+ let {
17
+ nodes,
18
+ links,
19
+ entries,
20
+ }: { nodes: GraphNode[]; links: GraphLink[]; entries: Record<string, IndexEntry> } = $props();
21
+
22
+ const legend: GraphLegend = {
23
+ kinds: [
24
+ { kind: 'math', label: 'Math note', shape: 'pill' },
25
+ { kind: 'entry-document', label: 'Archive document', shape: 'card' },
26
+ ],
27
+ solid: 'builds on',
28
+ dashed: 'links to',
29
+ from: 'Builds on',
30
+ to: 'Built on by',
31
+ related: 'Linked',
32
+ empty: 'Notes will appear here as they are written.',
33
+ };
34
+ </script>
35
+
36
+ <div class="document-map">
37
+ <Graph {nodes} {links} {entries} {legend} tuning={MAP_TUNING} />
38
+ </div>
@@ -0,0 +1,184 @@
1
+ <script lang="ts">
2
+ import type { Component } from 'svelte';
3
+
4
+ import { markdownHrefOf, type DocumentLink } from '../documents';
5
+ import type { DocumentData } from '../server/document';
6
+ import { KIND_LABELS, SITE, STATUS_LABELS } from '$site';
7
+ import { renderMixed } from '../tex';
8
+ import CopyCode from './CopyCode.svelte';
9
+ import Icon from './Icon.svelte';
10
+ import LinkList from './LinkList.svelte';
11
+ import PrevNext from './PrevNext.svelte';
12
+ import StageRail from './StageRail.svelte';
13
+ import Timeline from './Timeline.svelte';
14
+ import Toc from './Toc.svelte';
15
+
16
+ let { data }: { data: DocumentData & { component: Component } } = $props();
17
+ let body = $state<HTMLElement>();
18
+
19
+ const doc = $derived(data.doc);
20
+ const date = (d: Date) => d.toISOString().slice(0, 10);
21
+ const tex = (text: string) => renderMixed(text, doc.katexMacros as Record<string, string>);
22
+ const any = (...lists: DocumentLink[][]) => lists.some((list) => list.length);
23
+ // How much of an entry's summary "How this came to be" and "What it revises" show: an entry
24
+ // without one has its whole first paragraph, which is more than a list needs.
25
+ const EXCERPT = 200;
26
+ </script>
27
+
28
+ <svelte:head>
29
+ <title>{doc.title} · {SITE.name}</title>
30
+ <meta property="og:title" content="{doc.title} · {SITE.name}" />
31
+ <meta name="description" content={doc.summary} />
32
+ <meta property="og:description" content={doc.summary} />
33
+ <link rel="alternate" type="text/markdown" href={markdownHrefOf(doc.key)} />
34
+ </svelte:head>
35
+
36
+ <div class="doc-layout">
37
+ <article class="doc doc-{doc.kind}">
38
+ <header class="doc-header">
39
+ <p class="breadcrumb">
40
+ {#each data.crumbs as crumb, i (crumb.href)}
41
+ {#if i}<span class="sep" aria-hidden="true">/</span>{/if}<a href={crumb.href}
42
+ >{@html tex(crumb.title)}</a
43
+ >
44
+ {/each}
45
+ </p>
46
+ <h1>{@html tex(doc.title)}</h1>
47
+ {#if doc.summary}<p class="lede">{@html tex(doc.summary)}</p>{/if}
48
+ {#if doc.kind == 'entry'}
49
+ <p class="doc-meta">
50
+ <span class="chip">{KIND_LABELS[doc.workflow?.kind ?? ''] ?? 'Entry'}</span>
51
+ <span class="chip status-{doc.status}">{STATUS_LABELS[doc.status]}</span>
52
+ {#if doc.workflow?.started}<span>Started {doc.workflow.started}</span>{/if}
53
+ {#if doc.workflow?.finished}<span>· finished {doc.workflow.finished}</span>{/if}
54
+ </p>
55
+ {:else if doc.kind != 'page'}
56
+ <p class="doc-meta">
57
+ <span>Updated {date(doc.updated)}</span>
58
+ <span>· {doc.readingMinutes} min read</span>
59
+ </p>
60
+ {/if}
61
+ {#if data.prerequisites.length}
62
+ <div class="doc-builds-on">
63
+ <span class="label">Builds on</span>
64
+ <LinkList links={data.prerequisites} inline />
65
+ </div>
66
+ {/if}
67
+ </header>
68
+
69
+ {#if doc.kind == 'entry' && data.revisedBy.length}
70
+ <aside class="callout callout-note revised">
71
+ <p class="callout-title">Revised</p>
72
+ <p>The story this entry tells has since been changed by:</p>
73
+ <LinkList links={data.revisedBy} />
74
+ </aside>
75
+ {/if}
76
+
77
+ {#if data.amendedBy.length}
78
+ <aside class="callout callout-note revised">
79
+ <p class="callout-title">Amended</p>
80
+ <p>
81
+ {doc.kind == 'entry' ? 'This entry is' : 'This document is'} kept as it was approved,
82
+ but for references in it that have since been brought up to date by:
83
+ </p>
84
+ <LinkList links={data.amendedBy} />
85
+ </aside>
86
+ {/if}
87
+
88
+ <div class="prose" bind:this={body}>
89
+ <data.component />
90
+ </div>
91
+ <CopyCode root={body} />
92
+
93
+ {#if data.references.length}
94
+ <section class="references" aria-labelledby="references">
95
+ <h2 id="references">References</h2>
96
+ <ol>
97
+ {#each data.references as reference (reference.key)}
98
+ <li id="cite:{reference.key}">
99
+ <span class="reference-label">[{reference.label}]</span>
100
+ {@html reference.html}
101
+ </li>
102
+ {/each}
103
+ </ol>
104
+ </section>
105
+ {/if}
106
+
107
+ {#if doc.kind == 'entry'}
108
+ <section class="doc-context">
109
+ {#if doc.workflow}
110
+ <h2>Where it stands</h2>
111
+ <StageRail
112
+ kind={doc.workflow.kind}
113
+ stage={doc.workflow.stage}
114
+ approvals={doc.workflow.approvals as Record<string, { stale?: boolean }>}
115
+ />
116
+ {/if}
117
+ <h2>Documents</h2>
118
+ {#if data.documents.length}
119
+ <LinkList links={data.documents} cards />
120
+ {:else}
121
+ <p class="muted">Nothing is written yet.</p>
122
+ {/if}
123
+ {#if data.pages.length || data.changes.length || data.amends.length}
124
+ <h2>What it changed</h2>
125
+ {/if}
126
+ {#if data.pages.length}
127
+ <p>The pages that say what this entry made true:</p>
128
+ <LinkList links={data.pages} />
129
+ {/if}
130
+ {#each data.changes as group (group.intro)}
131
+ <p>{group.intro}</p>
132
+ <ul class="link-list">
133
+ {#each group.links as link (link.href)}
134
+ <li>
135
+ <a href={link.href}
136
+ >{#if link.code}<code>{link.label}</code
137
+ >{:else}{link.label}{/if}</a
138
+ >
139
+ </li>
140
+ {/each}
141
+ </ul>
142
+ {/each}
143
+ {#if data.amends.length}
144
+ <p>The documents of finished entries whose references it brought up to date:</p>
145
+ <LinkList links={data.amends} />
146
+ {/if}
147
+ {#if data.revises.length}
148
+ <h2>What it revises</h2>
149
+ <LinkList links={data.revises} excerpt={EXCERPT} />
150
+ {/if}
151
+ {#if doc.workflow?.events.length}
152
+ <h2>History</h2>
153
+ <Timeline events={doc.workflow.events} />
154
+ {/if}
155
+ </section>
156
+ {:else if any(data.entries, data.dependents)}
157
+ <section class="doc-context">
158
+ {#if data.entries.length}
159
+ <h2>How this came to be</h2>
160
+ <p>The development behind this page, newest first:</p>
161
+ <LinkList links={data.entries} excerpt={EXCERPT} />
162
+ {/if}
163
+ {#if data.dependents.length}
164
+ <h2>Built on by</h2>
165
+ <LinkList links={data.dependents} />
166
+ {/if}
167
+ </section>
168
+ {/if}
169
+
170
+ <footer class="doc-footer">
171
+ <a href={data.source} rel="external">
172
+ <Icon name="github" size={14} /> Edit this page
173
+ </a>
174
+ <a href={markdownHrefOf(doc.key)}>
175
+ <Icon name="file" size={14} /> View as Markdown
176
+ </a>
177
+ </footer>
178
+ <PrevNext prev={data.prev} next={data.next} />
179
+ </article>
180
+
181
+ <aside class="doc-aside">
182
+ <Toc headings={data.headings} />
183
+ </aside>
184
+ </div>
@@ -0,0 +1,35 @@
1
+ <script lang="ts">
2
+ // Inline 24×24 stroke icons, so the site needs no icon font.
3
+ const PATHS = {
4
+ sun: 'M12 4V2M12 22v-2M4.9 4.9 3.5 3.5M20.5 20.5l-1.4-1.4M4 12H2M22 12h-2M4.9 19.1l-1.4 1.4M20.5 3.5l-1.4 1.4M16 12a4 4 0 1 1-8 0 4 4 0 0 1 8 0Z',
5
+ moon: 'M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8Z',
6
+ menu: 'M3 6h18M3 12h18M3 18h18',
7
+ close: 'M18 6 6 18M6 6l12 12',
8
+ expand: 'M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7',
9
+ github: 'M9 19c-4.3 1.4-4.3-2.5-6-3m12 5v-3.5c0-1 .1-1.4-.5-2 2.8-.3 5.5-1.4 5.5-6a4.6 4.6 0 0 0-1.3-3.2 4.2 4.2 0 0 0-.1-3.2s-1.1-.3-3.5 1.3a12.3 12.3 0 0 0-6.2 0C6.5 2.8 5.4 3.1 5.4 3.1a4.2 4.2 0 0 0-.1 3.2A4.6 4.6 0 0 0 4 9.5c0 4.6 2.7 5.7 5.5 6-.6.6-.6 1.2-.5 2V21',
10
+ arrowLeft: 'M19 12H5M12 19l-7-7 7-7',
11
+ arrowRight: 'M5 12h14M12 5l7 7-7 7',
12
+ copy: 'M9 9h11v11H9zM5 15H4V4h11v1',
13
+ check: 'M20 6 9 17l-5-5',
14
+ file: 'M14 3H6v18h12V7l-4-4Zm0 0v4h4',
15
+ play: 'M7 4v16l13-8L7 4Z',
16
+ pause: 'M8 5v14M16 5v14',
17
+ restart: 'M5 4v16M19 20 9 12l10-8v16Z',
18
+ } as const;
19
+
20
+ let { name, size = 18 }: { name: keyof typeof PATHS; size?: number } = $props();
21
+ </script>
22
+
23
+ <svg
24
+ width={size}
25
+ height={size}
26
+ viewBox="0 0 24 24"
27
+ fill="none"
28
+ stroke="currentColor"
29
+ stroke-width="2"
30
+ stroke-linecap="round"
31
+ stroke-linejoin="round"
32
+ aria-hidden="true"
33
+ >
34
+ <path d={PATHS[name]} />
35
+ </svg>
@@ -0,0 +1,213 @@
1
+ <!--
2
+ A photo or screenshot in a document, which opens at the size of the window when clicked.
3
+
4
+ Import the image in the document's script, so that the build serves it under the base path, and
5
+ give its pixel size, so that the page keeps its place while it loads and the enlarged copy is as
6
+ large as the window allows without being letterboxed:
7
+
8
+ <ImageFigure src={board} alt="…" width={1200} height={1600}>The caption.</ImageFigure>
9
+
10
+ The image is a button: clicked, or pressed with Enter or Space, it opens a modal dialog, which
11
+ Escape, the close button or a click outside it closes. Hovering or focusing it lifts it and shows
12
+ an "Enlarge" badge, so that a reader sees it can be opened before trying. Adapted from skoro's
13
+ `ExampleFigure`, with an image in place of its inlined SVG.
14
+ -->
15
+ <script lang="ts">
16
+ import type { Snippet } from 'svelte';
17
+ import Icon from './Icon.svelte';
18
+
19
+ let {
20
+ src,
21
+ alt,
22
+ width,
23
+ height,
24
+ children,
25
+ }: { src: string; alt: string; width: number; height: number; children?: Snippet } = $props();
26
+
27
+ let dialog: HTMLDialogElement | undefined = $state();
28
+
29
+ function open() {
30
+ dialog?.showModal();
31
+ }
32
+
33
+ // A click on the backdrop lands on the dialog itself, outside its frame.
34
+ function closeOnBackdrop(event: MouseEvent) {
35
+ if (event.target == dialog) dialog?.close();
36
+ }
37
+ </script>
38
+
39
+ <figure class="image-figure">
40
+ <button
41
+ type="button"
42
+ class="opener"
43
+ onclick={open}
44
+ aria-haspopup="dialog"
45
+ aria-label={`Enlarge the image: ${alt}`}
46
+ >
47
+ <img {src} {alt} {width} {height} loading="lazy" />
48
+ <span class="badge" aria-hidden="true"><Icon name="expand" size={16} /> Enlarge</span>
49
+ </button>
50
+ {#if children}<figcaption>{@render children()}</figcaption>{/if}
51
+ </figure>
52
+
53
+ <dialog bind:this={dialog} class="figure-dialog" aria-label={alt} onclick={closeOnBackdrop}>
54
+ <div class="frame" style:--aspect={width / height}>
55
+ <img class="enlarged" {src} {alt} {width} {height} />
56
+ {#if children}<p class="dialog-caption">{@render children()}</p>{/if}
57
+ <form method="dialog">
58
+ <button class="close" aria-label="Close"><Icon name="close" size={20} /></button>
59
+ </form>
60
+ </div>
61
+ </dialog>
62
+
63
+ <style>
64
+ .image-figure {
65
+ margin: var(--space-6) 0;
66
+ }
67
+
68
+ .opener {
69
+ position: relative;
70
+ display: block;
71
+ margin: 0 auto;
72
+ padding: 0;
73
+ border: 0;
74
+ border-radius: var(--radius);
75
+ background: none;
76
+ cursor: zoom-in;
77
+ box-shadow: 0 8px 24px rgb(0 0 0 / 0.08);
78
+ transition:
79
+ transform 160ms ease,
80
+ box-shadow 160ms ease;
81
+ }
82
+
83
+ img {
84
+ display: block;
85
+ max-width: 100%;
86
+ height: auto;
87
+ border-radius: var(--radius);
88
+ }
89
+
90
+ /* A tall photo would fill the column, so its height is capped in place; the dialog shows it whole. */
91
+ .opener img {
92
+ max-height: 70vh;
93
+ width: auto;
94
+ }
95
+
96
+ .badge {
97
+ position: absolute;
98
+ top: 0.75rem;
99
+ right: 0.75rem;
100
+ display: inline-flex;
101
+ align-items: center;
102
+ gap: 0.35rem;
103
+ padding: 0.3rem 0.6rem;
104
+ border-radius: 999px;
105
+ background: var(--bg-1);
106
+ color: var(--fg-2);
107
+ font: var(--font-small);
108
+ box-shadow: var(--shadow-sm);
109
+ border: 1px solid var(--border);
110
+ opacity: 0;
111
+ transform: translateY(-2px);
112
+ transition:
113
+ opacity 160ms ease,
114
+ transform 160ms ease;
115
+ }
116
+
117
+ .opener:hover,
118
+ .opener:focus-visible {
119
+ transform: translateY(-3px);
120
+ box-shadow:
121
+ 0 0 0 2px var(--fg-accent),
122
+ 0 16px 36px rgb(0 0 0 / 0.14);
123
+ }
124
+
125
+ .opener:focus-visible {
126
+ outline: none;
127
+ }
128
+
129
+ .opener:hover .badge,
130
+ .opener:focus-visible .badge {
131
+ opacity: 1;
132
+ transform: none;
133
+ }
134
+
135
+ @media (prefers-reduced-motion: reduce) {
136
+ .opener,
137
+ .badge {
138
+ transition: none;
139
+ }
140
+
141
+ .opener:hover,
142
+ .opener:focus-visible {
143
+ transform: none;
144
+ }
145
+ }
146
+
147
+ figcaption {
148
+ margin-top: var(--space-3);
149
+ font: var(--font-small);
150
+ color: var(--fg-3);
151
+ text-align: center;
152
+ }
153
+
154
+ .figure-dialog {
155
+ /* Centred in the window: the site's reset takes the user agent's automatic margins away. */
156
+ margin: auto;
157
+ max-width: 96vw;
158
+ max-height: 96vh;
159
+ padding: 0;
160
+ border: 0;
161
+ background: transparent;
162
+ overflow: visible;
163
+ }
164
+
165
+ .figure-dialog::backdrop {
166
+ background: rgb(10 12 20 / 0.72);
167
+ backdrop-filter: blur(3px);
168
+ }
169
+
170
+ .frame {
171
+ position: relative;
172
+ }
173
+
174
+ .enlarged {
175
+ width: min(96vw, calc(86vh * var(--aspect)));
176
+ max-width: none;
177
+ box-shadow: 0 24px 64px rgb(0 0 0 / 0.35);
178
+ }
179
+
180
+ .dialog-caption {
181
+ margin: var(--space-3) auto 0;
182
+ max-width: 60rem;
183
+ text-align: center;
184
+ font: var(--font-small);
185
+ color: hsl(0 0% 92%);
186
+ }
187
+
188
+ form {
189
+ position: absolute;
190
+ top: 0.75rem;
191
+ right: 0.75rem;
192
+ margin: 0;
193
+ }
194
+
195
+ .close {
196
+ display: grid;
197
+ place-items: center;
198
+ width: 2.25rem;
199
+ height: 2.25rem;
200
+ border-radius: 999px;
201
+ border: 1px solid var(--border);
202
+ background: var(--bg-1);
203
+ color: var(--fg-1);
204
+ cursor: pointer;
205
+ box-shadow: var(--shadow-sm);
206
+ }
207
+
208
+ .close:hover,
209
+ .close:focus-visible {
210
+ border-color: var(--fg-accent);
211
+ color: var(--fg-accent);
212
+ }
213
+ </style>