@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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Matthew Varble
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,110 @@
1
- # Temporary Holding Version
1
+ # @mvarble/mesearch-workflow
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Documented development: every change to a project is an **entry** that moves through stages a person approves (a plan, a build, the pages that say what now is), and is kept, as it was approved, in an archive on the project's documentation site. This package is everything that is the same from project to project:
4
+
5
+ - **the engine**, `bin/wf`, which keeps each entry's record and refuses an edit its stage does not allow, configured by the project's `workflow.config.ts`;
6
+ - **the skills** that drive it (`/wf-start`, `/wf-plan`, `/wf-build`, `/wf-publish`, `/wf-approve`, …) and the procedure they follow;
7
+ - **the documentation site**: a SvelteKit app whose pages, math notes and archive are the project's `site/content/`, with the content database's preset, the routes, the components and the styles.
8
+
9
+ What differs between projects (their kinds of entry, their code, their stages' particulars, their tracks, their own components) stays in the project.
10
+
11
+ ```sh
12
+ pnpm add -D @mvarble/mesearch-workflow # in site/
13
+ pnpm exec mesearch-wf init # workflow.config.ts, AGENTS.md, a site, the guard, then sync
14
+ pnpm exec mesearch-wf sync # after an update: bring what is the package's up to date
15
+ pnpm exec mesearch-wf diff # in CI: fail if a managed file is not this version's
16
+ ```
17
+
18
+ ## A project
19
+
20
+ ```
21
+ workflow.config.ts the project's kinds, stages and code
22
+ AGENTS.md the project's own instructions to agents
23
+ bin/wf managed: runs the engine
24
+ .workflow/engine/ managed: the engine, vendored
25
+ .workflow/managed.json managed: what sync wrote, with each file's hash
26
+ .workflow/active the entry this branch works on, written by bin/wf
27
+ .agents/skills/wf-*/ managed: the workflow's skills (linked into .claude/skills/)
28
+ .agents/skills/<own>/ the project's own skills, such as a stage only it has
29
+ .agents/reference/mesearch/ managed: workflow.md, authoring.md, markup.md
30
+ .agents/reference/authoring.md the project's own writing conventions
31
+ .agents/reference/stages/<stage>.md what a stage asks of this project beyond its skill
32
+ .claude/settings.json runs `bin/wf guard` before every edit
33
+ site/ the documentation site (below)
34
+ ```
35
+
36
+ ### Managed files
37
+
38
+ A _managed_ file belongs to this package. `mesearch-wf sync` writes it, `.workflow/managed.json` records its hash, `bin/wf guard` refuses an edit to it (with a message saying where to make the change instead), and `bin/wf check` fails when it has changed, so CI catches an edit made around the guard. A change to one is made here and reaches every project with the next `sync`. A file a newer version no longer ships is removed by `sync`, unless it was changed in the project, in which case it is kept and reported.
39
+
40
+ The engine is vendored, as plain JavaScript with no dependencies, because the guard runs before every edit, including in a fresh clone where nothing is installed. It loads `workflow.config.ts` with Node's type stripping (Node 22.18 or later), so the config imports nothing but types:
41
+
42
+ ```ts
43
+ import type { WorkflowConfig } from '@mvarble/mesearch-workflow';
44
+
45
+ export default {
46
+ project: 'skoro', // as skills and messages name it: "skoro's development workflow"
47
+ code: [/^crates\//, /^Cargo\.(toml|lock)$/], // what opens at the build
48
+ describe: { code: '`crates/`, `Cargo.*`' }, // how the reference documents name it
49
+ kinds: {
50
+ feature: {
51
+ stages: ['math', 'implementation', 'plan', 'build', 'publish'],
52
+ describe: 'needs mathematics worked out',
53
+ },
54
+ chore: { stages: ['plan', 'build', 'publish'], describe: 'a port or a refactor' },
55
+ },
56
+ stages: {
57
+ math: { document: true, unlocks: ['math'] },
58
+ implementation: { document: true, sections: ['Tests'] },
59
+ plan: { document: true, checklist: true, editableDuring: ['build'] },
60
+ build: { unlocks: ['code'] },
61
+ publish: { unlocks: ['pages'] },
62
+ },
63
+ entryFields: { crates: '[]' }, // more frontmatter for a new entry's index.md
64
+ pagesOptional: ['chore'], // kinds whose publish need not change a page
65
+ checks: { publish: (context) => [] }, // the project's own conditions for approving a stage
66
+ } satisfies WorkflowConfig;
67
+ ```
68
+
69
+ | field | |
70
+ | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
71
+ | `kinds` | Each kind's stages, in order, and a sentence saying when an entry is of that kind. |
72
+ | `stages` | `document`: written as `<stage>.md` and frozen once approved. `unlocks`: `math`, `code` or `pages`, open from then on. `sections`: headings it must have. `checklist`: a plan, whose boxes are ticked later without reopening it. `editableDuring`: later stages that may still edit it. `skill`: `/wf-<stage>` by default. `describe`: what it produces. |
73
+ | `code`, `free` | What counts as code, and paths open at every stage (a ledger of facts, say). |
74
+ | `content`, `math` | `site/content` and `math` by default; `math: false` for a project without math notes. |
75
+ | `entryFields` | Frontmatter `bin/wf start` adds to a new entry. |
76
+ | `checks` | Per stage, a function of the entry (`root`, `slug`, `index`, `text`, `changed`, `list(field)`) returning problems, which `wf approve` reports beside its own. |
77
+
78
+ `build` and `publish` are stages the engine knows by name: a build is approved only when every checklist box is ticked and the tree is clean, and a publish only when the pages it changed are listed in the entry's `pages` and what it changed in done entries in its `amends`.
79
+
80
+ ### Skills
81
+
82
+ `sync` writes `wf-start`, `wf-approve`, `wf-reopen`, `wf-abandon`, `wf-resume`, `wf-status` and the stage skills `wf-plan`, `wf-build`, `wf-publish` and `wf-writeup`, filled in with the project's name and kinds. A stage skill holds what every project's stage does, and reads `.agents/reference/stages/<stage>.md` for what this project's does besides (what to read first, the plan's template, how a task is checked, which pages a publish changes). A stage only one project has, such as skoro's `math` or a measurement stage, is that project's own skill, written beside the managed ones; it reads `.agents/reference/mesearch/workflow.md` for the procedure.
83
+
84
+ ## The documentation site
85
+
86
+ ```ts
87
+ // site/vite.config.ts
88
+ import { docsSite } from '@mvarble/mesearch-workflow/site';
89
+ import { defineConfig } from 'vite';
90
+
91
+ export default defineConfig({ plugins: await docsSite() });
92
+ ```
93
+
94
+ `docsSite()` sets up the content database with the docs preset, SvelteKit with mdsvex (KaTeX, callouts, heading anchors, quoted code), and two virtual modules through which the app reads the project:
95
+
96
+ | `$site` | from |
97
+ | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
98
+ | structure | `src/lib/site.ts`: `SITE`, `TRACKS`, `MATH`, `ARCHIVE`, `DOCUMENTS`, and optionally `MATH_PARTS`, `KIND_LABELS`, `STATUS_LABELS`, `NAV` (`mathBefore`), `LLMS` (`about`), `THEME_KEY` |
99
+ | logo | `src/lib/components/Logo.svelte`, as `<Logo variant="icon" \| "lockup" />` |
100
+ | macros | `katex.config.ts` |
101
+ | stages | `../workflow.config.ts`, for the archive's stage rail |
102
+ | `$site/server` | `src/lib/server/site.ts`, if any: `hooks: SiteHooks`, with `entryChanges` (what an entry's page lists under "What it changed" besides its pages) and `markdown` (rewrites for the Markdown export of a component of the site's own) |
103
+
104
+ `sync` writes a wrapper of a few lines for every route the app ships (`src/routes/…`, `src/params/…`) and for what documents import by `$lib` path (`Statement`, `Proof`, `ModelGraph`, `ImageFigure`, `TrackCard`, `graph/spec`). The site keeps its home page and layout, built from `Shell` and the app's other components (`@mvarble/mesearch-workflow/app/lib/components/…`), its colours (`src/styles/tokens/colors.css`, beside `@mvarble/mesearch-workflow/styles/index.css`), and any route and component of its own. `src/app.d.ts` takes the virtual modules' types with `/// <reference types="@mvarble/mesearch-workflow/ambient" />`.
105
+
106
+ The site's `Statement`, `Proof`, `Toc`, `ThemeToggle` and `Icon` share names with [`@mvarble/mesearch-ui`](../ui)'s but not their markup: these are the documentation site's look, which skoro and autonomy-fusion-box had.
107
+
108
+ ## Development
109
+
110
+ `test/engine/` runs the engine against configs shaped like skoro's and autonomy-fusion-box's, each with the test suite its repository had. `test/preset/` runs the preset against both repositories' fixtures. `test/sync/` sets up throwaway repositories and runs the vendored engine in them with nothing installed. The app itself is built, type-checked and tested by [`docs-example/`](../../docs-example), a site with a document of every kind.
@@ -0,0 +1,142 @@
1
+ # Writing a project's documentation
2
+
3
+ How the documents in `site/content/` are written in a project documented through
4
+ `@mvarble/mesearch-workflow`: what each kind promises, where it goes, its frontmatter, links,
5
+ prose, callouts, code and figures. `markup.md`, beside this file, says how mathematics, numbered
6
+ equations, statements and citations are written.
7
+
8
+ This file and `markup.md` belong to the package, and `mesearch-wf sync` replaces them with the
9
+ current version, so they are never edited here. The project's own conventions are in
10
+ `.agents/reference/authoring.md`: what its site is for, its tracks, its notation, and anything it
11
+ does differently. Where the two differ, the project's file wins.
12
+
13
+ ## Three kinds of writing
14
+
15
+ - **Pages say what is.** They describe the project as it stands, quote the code that exists, and
16
+ only ever describe the current state. They are rewritten whenever the project changes, at an
17
+ entry's `publish` stage, and are grouped in tracks (`TRACKS` in `site/src/lib/site.ts`).
18
+ - **Math notes say what is true**, independently of the project: one idea to a note, at enough
19
+ length to be worth reading alone. A note the site already has is linked, never rewritten in
20
+ another document.
21
+ - **Archive documents discuss what may be.** They argue, weigh alternatives and leave room for
22
+ doubt, as they stood when approved. Once approved they are frozen: they may drift from the code,
23
+ and that is what they are for.
24
+
25
+ Before writing about an idea, search for it: `grep -rni '<the idea>' site/content/`. If the site
26
+ explains it, link there.
27
+
28
+ ## Where things go
29
+
30
+ ```
31
+ site/content/
32
+ landing.md the home page's prose
33
+ <track>/<slug>/index.md a page of a track
34
+ math/<slug>/index.md a math note
35
+ archive/<slug>/index.md an entry, opened by `bin/wf start`
36
+ archive/<slug>/<stage>.md its documents, one per stage that has one
37
+ archive/<slug>/statements/<x>.md statements its documents show
38
+ references.bib the bibliography
39
+ ```
40
+
41
+ A document is `.md`, or `.svx` when it imports a component. Anything else a document uses
42
+ (images, figure specs, data) goes in its own folder and is referenced relatively.
43
+
44
+ ## Frontmatter
45
+
46
+ ```yaml
47
+ ---
48
+ title: Retractions
49
+ summary: Maps from a tangent space back onto the manifold. # one plain sentence
50
+ depends_on: [tangent-space, archive/normal/math]
51
+ katex_macros:
52
+ '\retr': '\operatorname{R}'
53
+ ---
54
+ ```
55
+
56
+ - `title` may contain inline math. An entry's documents default to their stage's name
57
+ ("Mathematics", "Plan"), which is usually right.
58
+ - `summary` is shown in lists, the sidebar, previews and `llms.txt`. Without it, the first
59
+ paragraph stands in, so either write one or make the first paragraph a good summary.
60
+ - `depends_on` lists what a reader must understand first: a bare slug is a math note, anything
61
+ else a key (`concepts/graph`, `archive/normal/math`). These are the solid arrows of the map on
62
+ the Mathematics page, so list real prerequisites, not everything mentioned.
63
+ - A page also needs `order`, its place in its track. Its `depends_on` names no page of its own
64
+ track at its place or after it.
65
+ - Where the mathematics has parts (`MATH_PARTS` in `site/src/lib/site.ts`), a math note needs
66
+ `part` and `order`, its part and its place within it, and its `depends_on` names math notes
67
+ alone, none at its own place or after it. The build refuses a note that breaks either rule.
68
+ - A page that moves lists the keys it had under `formerly` (`formerly: [start/old-slug]`), so
69
+ that the entries that name it, frozen once done, still resolve to it.
70
+ - An entry's `index.md` lists the `pages` it changed (written at `publish`), the entries it
71
+ `revises` (given to `wf start`), and what it `amends` in entries that are done (`workflow.md`,
72
+ under "Amending a done entry"), with whatever else the project's workflow asks of it.
73
+
74
+ ## Mathematics, statements and citations
75
+
76
+ As `markup.md` says, with this site's particulars:
77
+
78
+ - The site-wide KaTeX macros are in `site/katex.config.ts`; notation for one document goes in its
79
+ `katex_macros`.
80
+ - A reference into another document names it by its key: `[](eq:math/<slug>/<tag>)`,
81
+ `[%full](statement:archive/<entry>/<document>/<name>)`.
82
+ - `Statement` and `Proof` are imported from `$lib/components/Statement.svelte` and
83
+ `$lib/components/Proof.svelte`.
84
+ - Bibliography entries go in `site/content/references.bib`.
85
+
86
+ ## Links
87
+
88
+ - Write links the way the files sit on disk: `[retractions](../../math/retraction/)`,
89
+ `[the plan](plan.md)`, `[the guide](../../guide/)`. The build rewrites them to the site's URLs
90
+ and reports a link to a document that does not exist.
91
+ - A section's anchor is its heading in lowercase, with `$` removed and every run of characters
92
+ other than `a`–`z` and digits turned into one hyphen: `## Fubini's theorem` is
93
+ `#fubini-s-theorem`. Anchors are not checked, so work them out from the heading as written.
94
+ - Never put a link inside a heading.
95
+
96
+ ## Prose
97
+
98
+ Write in complete sentences and paragraphs, in the register of a textbook, with tables and lists
99
+ only where they genuinely help. Never refer to the conversation that produced a document: it is
100
+ read later, by someone who was not there. Prefer a concrete example to an abstract definition
101
+ alone. Name things the way the code names them, in backticks; generics such as `Q<B, M>` must be
102
+ in backticks anyway, since `<` and `{` are Svelte syntax outside code and math.
103
+
104
+ ## Callouts
105
+
106
+ GitHub-style blockquotes, with an optional title after the marker:
107
+
108
+ ```
109
+ > [!DECISION] Why conditioning belongs to the query
110
+ > ...
111
+ ```
112
+
113
+ `NOTE`, `TIP`, `WARNING`, `DECISION`, `TODO`. A `[!TODO]` is an open question: `wf approve`
114
+ refuses a document that still has one, so a draft carries its open questions as `[!TODO]`s until
115
+ they are answered. A page's `[!DECISION]` says briefly why something is the way it is and links
116
+ to the archive entry that decided it.
117
+
118
+ ## Code
119
+
120
+ - **Pages quote real code.** A fence whose only line is `{path}` or `{path:start..end}` is
121
+ replaced by those lines of the file (1-indexed, inclusive), with a caption linking to the
122
+ repository. Paths are relative to the document. Quoting Rust doc comments renders them as
123
+ Markdown.
124
+ - **Archive documents never quote with `{path}`.** The quote is re-read at every build, so it
125
+ would change as the code does, and a line range would eventually break the build. Sketch the
126
+ code inline, and when an existing interface matters, paste the lines and name the file and the
127
+ commit they were read at.
128
+ - Sketches are compile-plausible, and show signatures and types rather than bodies, unless the
129
+ body is the point.
130
+
131
+ ## Figures
132
+
133
+ - **A graph** (a model, a factor graph, a timing chain, a wiring diagram) is drawn with
134
+ `<ModelGraph spec={name} />`, from `$lib/components/ModelGraph.svelte`, with the spec in a
135
+ `*.graph.ts` file beside the document, written with `defineGraph` from `$lib/graph/spec`. The
136
+ Markdown export describes it in words.
137
+ - **An image** is imported in the document's `<script>` (`import board from './board.jpg'`), so
138
+ the build serves it under the site's base path, and placed with
139
+ `<ImageFigure src={board} alt="…" width={…} height={…}>caption</ImageFigure>`, from
140
+ `$lib/components/ImageFigure.svelte`, which opens it enlarged when clicked. Its alt text says
141
+ what the image shows for a reader who cannot see it, and its caption why it is there.
142
+ - **Anything else** is a Svelte component in the document's folder, referenced relatively.
@@ -0,0 +1,118 @@
1
+ # The development workflow
2
+
3
+ Every change to {{project}}'s code is an **entry** in the archive (`{{content}}/archive/<slug>/`),
4
+ worked on in a branch of its own and moved through **stages**. A person approves each stage;
5
+ nothing advances by itself. `bin/wf` keeps the record and enforces the rules; the `wf-*` skills
6
+ do the work of each stage.
7
+
8
+ This file is the procedure. `AGENTS.md` says when it applies (only when the user invokes one of
9
+ its commands). `authoring.md` and `markup.md` beside this file say how to write the documents,
10
+ `.agents/reference/authoring.md` what this project writes differently, and
11
+ `.agents/reference/stages/` what this project's stages ask beyond what their skills say.
12
+
13
+ This file belongs to `@mvarble/mesearch-workflow`, which writes it from `workflow.config.ts`
14
+ whenever `mesearch-wf sync` runs. Never edit it here: say what the project does differently in
15
+ `AGENTS.md`, or change the workflow upstream.
16
+
17
+ ## Kinds and stages
18
+
19
+ {{kinds-table}}
20
+
21
+ Each stage, what it produces, and the skill that works on it:
22
+
23
+ {{stages-table}}
24
+
25
+ And the commands that move an entry, all of them the user's to give:
26
+
27
+ | command | `bin/wf` |
28
+ | --------------------------------- | ------------------------------------------ |
29
+ | `/wf-start <slug> <kind> [about]` | `wf start <slug> --kind <kind> --title ...` |
30
+ | `/wf-approve` | `wf approve` |
31
+ | `/wf-reopen <stage> <reason>` | `wf reopen <stage> --reason ...` |
32
+ | `/wf-abandon <reason>` | `wf abandon --reason ...` |
33
+ | `/wf-resume <slug>` | `wf resume <slug>` |
34
+ | `/wf-status` | `wf status` |
35
+
36
+ `bin/wf kinds` lists the kinds as `workflow.config.ts` defines them.
37
+
38
+ ## What the stages guarantee
39
+
40
+ `bin/wf check` verifies these on every pull request; `bin/wf guard`, a Claude Code hook in
41
+ `.claude/settings.json`, refuses an edit that breaks one before it is made.
42
+
43
+ 1. **One entry per branch.** `.workflow/active` names it. A branch changes the files of one entry
44
+ only, and merges into `main` only once that entry is done or abandoned. What the entry
45
+ [amends](#amending-a-done-entry) in entries that are done is the one exception.
46
+ 2. **An approved document is frozen.** Its hash is recorded when it is approved, and it may change
47
+ again only after its stage is reopened. A checklist is the exception that proves the rule: its
48
+ boxes are ticked at a later stage, and nothing else in it changes. Once its entry is done, a
49
+ document changes only by an [amendment](#amending-a-done-entry).
50
+ 3. **Documents come in order.** A stage's document is not written before the stage.
51
+ 4. **Areas open as the entry advances.** {{areas}}
52
+ 5. **Approval is a gate, not a formality.** `wf approve` refuses {{gates}}
53
+
54
+ Anything outside these areas (the workflow's tool, the skills, the site's own code) is not gated.
55
+
56
+ ## Managed files
57
+
58
+ `mesearch-wf sync` writes the files that belong to `@mvarble/mesearch-workflow` rather than to the
59
+ project: `bin/wf` and the engine in `.workflow/engine/`, the skills it ships, this file and the
60
+ others in `.agents/reference/mesearch/`, and the documentation site's shared routes and
61
+ components. `.workflow/managed.json` lists them with their hashes. `bin/wf guard` refuses an edit
62
+ to one, and `bin/wf check` fails when one has changed. A change to one is made upstream, in
63
+ `@mvarble/mesearch-workflow`, and comes back with the next `sync`.
64
+
65
+ ## Going back
66
+
67
+ A stage's work sometimes shows that an earlier stage was wrong. Do not work around it: stop and
68
+ tell the user what was found. If they agree, they ask for `/wf-reopen <stage> <reason>`, which
69
+ moves the entry back, marks every approval from that stage on as needing renewal, and records the
70
+ reason in the entry's history. The reopened document gets a `## Revisions` section saying what
71
+ changed and why; each later stage is approved again on the way forward (unchanged, if nothing in
72
+ it had to change).
73
+
74
+ The story is allowed to change. It is not allowed to forget: the history shows every reopening,
75
+ and git keeps every draft.
76
+
77
+ ## A finished entry
78
+
79
+ When `publish` is approved the entry is done, `.workflow/active` is removed, and the branch is
80
+ ready to merge. A done entry's argument is never edited again. When {{project}} later changes what
81
+ an entry built, a new entry says so with `--revises <slug>`; the site then marks the old entry as
82
+ revised, and the pages show both under "How this came to be".
83
+
84
+ An entry set aside with `/wf-abandon` keeps its documents, approved or not, and can be taken up
85
+ again with `/wf-resume`.
86
+
87
+ ## Amending a done entry
88
+
89
+ The archive's documents refer to what changes after them: math notes and their equations and
90
+ statements, pages and their headings, anything else the project keeps current. A reference is
91
+ kept true: it follows what moves, and where what it cited is gone, the document says in a few
92
+ words what it was. That is the one change a done entry admits. What it claimed, measured and
93
+ weighed stays as it was approved.
94
+
95
+ - Only at its `publish` stage may an entry change another's files, and only a done entry's stage
96
+ documents ({{documents}}) and statements. `bin/wf guard` refuses anything else.
97
+ - The entry lists what it changed under `amends` in its `index.md`: a document as
98
+ `archive/<slug>/<stage>`, a statement as `archive/<slug>/statements/<name>`.
99
+ - `wf approve` refuses the publish if a done entry's file changed and is not listed, or is listed
100
+ and did not change. On approval it writes the amended document's new hash into the amended
101
+ entry's `workflow.json`, with an `amend` event naming the amending entry. The commit of the
102
+ document's own approval stays in the record, and is where its text before the amendment is.
103
+ Commit every `workflow.json` it names.
104
+ - Nothing mechanical limits an amendment to references: the person who approves the publish reads
105
+ the diff. Never use an amendment to change what a document argues or measured; that is what a
106
+ new entry with `--revises` is for.
107
+
108
+ ## Revisions within a stage
109
+
110
+ A stage is a conversation. Each time the user asks a question or a change, the document is
111
+ revised, and each revision is committed: the archive keeps the final draft, and git keeps the
112
+ back-and-forth. The archive itself does not record the drafts, only the final text and any
113
+ reopenings.
114
+
115
+ ## Before pushing
116
+
117
+ Run `bin/wf check`, which checks the rules above against `origin/main`, and the project's own
118
+ checks, which `AGENTS.md` lists.
@@ -0,0 +1,18 @@
1
+ ---
2
+ name: wf-abandon
3
+ description: Set the active entry aside, keeping its documents in the archive, in {{project}}'s development workflow. Use only when the user invokes /wf-abandon.
4
+ disable-model-invocation: true
5
+ argument-hint: '<reason>'
6
+ ---
7
+
8
+ # /wf-abandon: set an entry aside
9
+
10
+ ## Steps
11
+
12
+ 1. Get the reason from the user if they gave none: it is shown in the archive.
13
+ 2. Commit any work on the entry's documents the user wants kept; uncommitted drafts of code
14
+ should be discarded or committed only if the user says so.
15
+ 3. Run `bin/wf abandon --reason "<reason>"`.
16
+ 4. Commit what it changed ("Set <slug> aside: <reason>").
17
+ 5. Reply that the entry's documents stay in the archive, and that `/wf-resume <slug>` takes it up
18
+ again on any branch.
@@ -0,0 +1,24 @@
1
+ ---
2
+ name: wf-approve
3
+ description: Record the user's approval of the active entry's current stage and move it to the next, in {{project}}'s development workflow. Use only when the user invokes /wf-approve; never on your own judgment.
4
+ disable-model-invocation: true
5
+ argument-hint: ''
6
+ ---
7
+
8
+ # /wf-approve: approve the current stage
9
+
10
+ The user has read the stage's work and accepts it. Their invoking this skill is the approval; it
11
+ is never given on their behalf.
12
+
13
+ ## Steps
14
+
15
+ 1. Run `bin/wf status` and say which stage of which entry is being approved.
16
+ 2. If the stage's document, or anything the stage changed, is uncommitted, show the user what is
17
+ uncommitted and ask whether to commit it as part of the approval. Do not commit work the user
18
+ has not seen.
19
+ 3. Run `bin/wf approve`. If it refuses, report each problem it lists and stop: the stage is not
20
+ done. Do not fix the problems in the same breath; the user decides what happens next.
21
+ 4. Commit what `wf` changed (`workflow.json`, the `workflow.json` of every entry it amended, and
22
+ `.workflow/active` when the entry is finished) as "Approve the <stage> of <slug>".
23
+ 5. Reply with the next stage and its skill. When the entry is done, say so, and that the branch
24
+ can be merged once `bin/wf check --merge` passes.
@@ -0,0 +1,45 @@
1
+ ---
2
+ name: wf-build
3
+ description: Build the active entry by working through its approved plan, task by task, with a check and a commit per task, in {{project}}'s development workflow. Use only when the user invokes /wf-build.
4
+ disable-model-invocation: true
5
+ argument-hint: '[a task to start from, or a limit such as "the first three"]'
6
+ ---
7
+
8
+ # /wf-build: the build
9
+
10
+ Work through `plan.md` in order: do each task, check it, tick its box, commit.
11
+
12
+ ## Before anything
13
+
14
+ Run `bin/wf status --expect build`. If it fails, stop and tell the user what it said.
15
+
16
+ Read `.agents/reference/mesearch/workflow.md` once per session, the entry's `plan.md` and the
17
+ documents it was distilled from, the rules in `AGENTS.md`, and `.agents/reference/stages/build.md`
18
+ if the project has it: how a task is checked here, and what else a build does.
19
+
20
+ ## Each task
21
+
22
+ 1. Do exactly what the task says. Details it leaves open (private helpers, local names, the order
23
+ of statements) are yours to decide.
24
+ 2. Check it as the task and the project's build steps say. Do not move on with anything failing.
25
+ A task only the user can do (at a bench, say) is done by them, or with them: say what to run
26
+ and what to expect, and do not tick the box until they report the result.
27
+ 3. Tick the task's box in `plan.md`; change nothing else in the plan, since `wf check` refuses any
28
+ other edit to it.
29
+ 4. Commit, with a message saying what the task added.
30
+
31
+ Commit often, push when your environment expects it, and report progress between tasks when the
32
+ user asked for only some of them.
33
+
34
+ ## When the plan is wrong
35
+
36
+ If a task cannot be done as planned (an interface does not allow it, a check shows an earlier
37
+ document wrong, the plan misses a step), stop. Tell the user what was found and which stage it
38
+ belongs to, and suggest `/wf-reopen <stage> <reason>`. Do not deviate from the plan quietly, and
39
+ never edit an approved document.
40
+
41
+ ## At the end
42
+
43
+ When every box is ticked, run the plan's "Done when" checks and `bin/wf check`, and whatever else
44
+ the project's build steps ask at the end. Reply that `/wf-approve` moves on. Never approve
45
+ yourself.
@@ -0,0 +1,49 @@
1
+ ---
2
+ name: wf-plan
3
+ description: Write or revise the plan of the active entry, a checklist the build works through in order, in {{project}}'s development workflow. Use only when the user invokes /wf-plan.
4
+ disable-model-invocation: true
5
+ argument-hint: '[what to change]'
6
+ ---
7
+
8
+ # /wf-plan: the plan
9
+
10
+ What will be done, in order, and how anyone will know it worked: a checklist that the build works
11
+ through task by task. Whatever the plan rests on is already decided, in an earlier stage or in a
12
+ decision entry; a choice that is expensive to reverse does not belong buried in a task.
13
+
14
+ ## Before anything
15
+
16
+ Run `bin/wf status --expect plan`. If it fails, stop and tell the user what it said.
17
+
18
+ Read `.agents/reference/mesearch/workflow.md` once per session, the entry's `index.md`, and
19
+ `.agents/reference/stages/plan.md` if the project has it: what this project's plan is distilled
20
+ from, what else to read first, and the plan's template. If writing the plan shows a hole in an
21
+ earlier stage, stop and suggest `/wf-reopen <stage> <reason>` rather than deciding it here.
22
+
23
+ ## Writing
24
+
25
+ `{{content}}/archive/<slug>/plan.md`, in groups of tasks, each a box:
26
+
27
+ ```markdown
28
+ ---
29
+ summary: <one sentence>
30
+ ---
31
+
32
+ ## <Group>
33
+
34
+ - [ ] <One task, small enough for one commit, and how to know it is done.>
35
+ - [ ] ...
36
+
37
+ ## Done when
38
+
39
+ <The checks that must pass at the end.>
40
+ ```
41
+
42
+ The project's template, where it has one, says what else the plan holds and how a task names its
43
+ check.
44
+
45
+ - Order the tasks so that each builds on finished ones, and what is built works after each.
46
+ - A task says what to do, not how: the how is decided in an earlier stage or in the build.
47
+
48
+ Commit each revision. When the plan is right, reply that `/wf-approve` starts the build. Never
49
+ approve yourself.
@@ -0,0 +1,42 @@
1
+ ---
2
+ name: wf-publish
3
+ description: Bring {{project}}'s documentation pages up to date with what the active entry built or decided, and link the entry to them; the last stage of {{project}}'s development workflow. Use only when the user invokes /wf-publish.
4
+ disable-model-invocation: true
5
+ argument-hint: '[pages to start with, or what to change]'
6
+ ---
7
+
8
+ # /wf-publish: the pages
9
+
10
+ The entry is built (or, for a decision, argued). Now the pages that say what {{project}} _is_ must
11
+ say it. The archive discussed what might be; the pages tell what is.
12
+
13
+ ## Before anything
14
+
15
+ Run `bin/wf status --expect publish`. If it fails, stop and tell the user what it said.
16
+
17
+ Read `.agents/reference/mesearch/authoring.md` and `.agents/reference/authoring.md` once per
18
+ session, the entry's documents, and the code it added, and `.agents/reference/stages/publish.md`
19
+ if the project has it: which pages an entry of each kind changes, and what else the publish lists.
20
+ Read the pages that are affected (the tracks under `{{content}}/`, the landing page) before
21
+ changing them.
22
+
23
+ ## Writing
24
+
25
+ - **The pages.** Add or rewrite the pages that describe what now exists, quoting the real code
26
+ with `{path:start..end}` fences, and linking the math notes for the mathematics. A choice a reader
27
+ would wonder about gets a short `> [!DECISION]` linking the entry that made it.
28
+ - **Drop what is no longer true.** A page describes only what now is. What a revised entry built
29
+ and this one replaced disappears from the pages; it stays in the archive.
30
+ - **The entry's `index.md`.** Replace its opening paragraph with what the entry did, for a reader
31
+ of the archive, and list every page it changed under `pages`, with whatever else the project's
32
+ publish lists. `wf approve` refuses a changed page that is not listed, and a listed one the
33
+ branch did not change.
34
+ - **What it amends.** Where the entry moved or removed something a done entry's document refers to
35
+ (a math note's equation, a page, a heading), change that reference in the done entry's document,
36
+ and list it under `amends` in the entry's `index.md` (`workflow.md`, under "Amending a done
37
+ entry"). Change nothing else there.
38
+
39
+ Build the site (`cd site && pnpm build`) and fix every warning and broken link. Commit as you go.
40
+
41
+ When the pages are right, run `bin/wf check` and reply that `/wf-approve` finishes the entry,
42
+ after which the branch is ready to merge. Never approve yourself.
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: wf-reopen
3
+ description: Move the active entry back to an earlier stage so its approved document can be revised, recording why, in {{project}}'s development workflow. Use only when the user invokes /wf-reopen.
4
+ disable-model-invocation: true
5
+ argument-hint: '<stage> <reason>'
6
+ ---
7
+
8
+ # /wf-reopen: go back to an earlier stage
9
+
10
+ ## Steps
11
+
12
+ 1. Work out the stage and the reason from what the user wrote; ask for the reason if there is
13
+ none. It is recorded in the entry's history, so make it one plain sentence about what was
14
+ wrong.
15
+ 2. Run `bin/wf reopen <stage> --reason "<reason>"`. If it refuses, tell the user what it said and
16
+ stop.
17
+ 3. In the reopened stage's document, add (or extend) a `## Revisions` section at its end with a
18
+ dated paragraph: what is being changed, and why. Fill in what actually changed as the revision
19
+ is made.
20
+ 4. Commit `workflow.json` and the document ("Reopen the <stage> of <slug>: <reason>").
21
+ 5. Reply with the reopened stage's skill. Every later stage will be approved again on the way
22
+ forward.
@@ -0,0 +1,16 @@
1
+ ---
2
+ name: wf-resume
3
+ description: Take up an abandoned entry again at the stage it was left, in {{project}}'s development workflow. Use only when the user invokes /wf-resume.
4
+ disable-model-invocation: true
5
+ argument-hint: '<slug>'
6
+ ---
7
+
8
+ # /wf-resume: take an entry up again
9
+
10
+ ## Steps
11
+
12
+ 1. If the current branch is `main`, make a branch first (`git switch -c <slug>`), unless your
13
+ environment names the branch to work on.
14
+ 2. Run `bin/wf resume <slug>`. If it refuses, tell the user what it said and stop.
15
+ 3. Commit `workflow.json` and `.workflow/active` ("Resume <slug>").
16
+ 4. Read the entry's documents, then reply with where it stands and the stage's skill.