@canopy-iiif/app 0.7.14 → 0.7.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/AGENTS.md ADDED
@@ -0,0 +1,66 @@
1
+ Lib Agent Notes
2
+ ===============
3
+
4
+ Mission
5
+ -------
6
+ - Provides the Node-side builder, SSR utilities, and client runtime bundles consumed by the static site.
7
+ - Owns IIIF ingestion, MDX compilation, site generation, and search indexing.
8
+
9
+ Core Areas
10
+ ----------
11
+ - `build/`: Orchestrates the site build pipeline (MDX, assets, search, IIIF).
12
+ - `components/`: Shared SSR-ready React components (MDX placeholders, layout helpers).
13
+ - `iiif/`: Fetching, caching, and normalizing Presentation 3 manifests.
14
+ - `search/`: Search runtime bundler + index writer.
15
+ - `common.js` / `index.js`: Entry points that wire CLI commands `build()` and `dev()`.
16
+
17
+ Invariants
18
+ ----------
19
+ - Server code must import UI through `@canopy-iiif/app/ui/server`; never pull browser-only modules into SSR paths.
20
+ - Bundled runtimes rely on browser React globals from `site/scripts/react-globals.js`; maintain esbuild shims for `react`, `react-dom`, `react-dom/client`, `flexsearch`, and any new browser deps the UI marks external.
21
+ - Keep IIIF cache writes confined to `.cache/iiif/`; document any format changes here before implementation.
22
+
23
+ Active Cleanup Goals
24
+ --------------------
25
+ 1. Document and untangle build orchestration in `build/` (identify stages, shared utilities, and intended extension points).
26
+ 2. Expand search indexing to include MDX page records per repository guidelines; ensure `writeSearchIndex` receives unified records.
27
+ 3. Audit IIIF pipeline error handling and retry logic; capture gaps or performance tweaks in this log.
28
+ 4. Establish targeted unit/integration tests around MDX rendering and search runtime bundling once baseline docs exist.
29
+
30
+ Current Focus
31
+ -------------
32
+ - Build pipeline map: diagram the flow from `build/index.js` through MDX compilation, asset sync, IIIF generation, and search index writes; note which steps run during `dev` versus `build`.
33
+ - Search index expansion: confirm where MDX pages are collected, identify reserved filenames to exclude, and outline the data contract passed to `writeSearchIndex`.
34
+ - Runtime bundling: review `search/search.js` for esbuild config drift (externals, shims); list required adjustments if UI adds new hydrated components.
35
+ - Cache hygiene: document when `.cache/mdx` vs `.cache/iiif` are pruned and add TODOs if cleanup relies on manual intervention.
36
+
37
+ Risks & Watchpoints
38
+ -------------------
39
+ - Long reruns: if `dev` mode clears `.cache/iiif` too aggressively it slows iteration; capture triggers before modifying cleanup behavior.
40
+ - SSR safety: any import path change that reaches into `ui/src` instead of `ui/server` will break builds on platforms without DOM. Flag code locations handling UI imports.
41
+ - Partial failures: build stages lack retry/backoff; note hotspots (network IIIF fetches, MDX parsing) so we can stage resilience work.
42
+
43
+ Session Ritual
44
+ --------------
45
+ - Start by checking `build/index.js` for any ad-hoc logic that should be modularised.
46
+ - When touching bundler configs, record the rationale plus command to verify (e.g., `npm run build`, targeted script).
47
+ - Log open TODOs with references back to this document (`// TODO: see packages/app/lib/AGENTS.md#...`).
48
+
49
+ Logbook Template
50
+ ----------------
51
+ - Date / engineer
52
+ - Stage(s) touched (build, mdx, iiif, search, runtime)
53
+ - Changes made / findings (link to sections above)
54
+ - Follow-ups created (reference numbered goals)
55
+
56
+ Logbook
57
+ -------
58
+ - 2025-09-26 / chatgpt: Hardened runtime bundlers to throw when esbuild or source compilation fails and required `content/works/_layout.mdx`; build now aborts instead of silently writing placeholder assets.
59
+ - 2025-09-26 / chatgpt: Replaced the legacy command runtime stub with an esbuild-bundled runtime (`search/command-runtime.js`); `prepareCommandRuntime()` now builds `site/scripts/canopy-command.js` and fails if esbuild is missing.
60
+ - 2025-09-27 / chatgpt: Documented Tailwind token flow in `app/styles/tailwind.config.js`, compiled UI Sass variables during config load, and exposed `stylesheetHref`/`Stylesheet` helpers via `@canopy-iiif/app/head` so `_app.mdx` can reference the generated CSS directly.
61
+ - 2025-09-27 / chatgpt: Expanded search indexing to harvest MDX pages (respecting frontmatter/layout types), injected BASE_PATH hydration data into search.html, and reworked `mdx.extractTitle()` so generated records surface real headings instead of `Untitled`.
62
+
63
+ Verification Commands
64
+ ---------------------
65
+ - Full pipeline: `npm run build`
66
+ - Dev/watch validation: `npm run dev`