@abstractdata/starlight-theme 0.3.2 → 0.3.3

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.
@@ -1,32 +1,27 @@
1
1
  ---
2
2
  name: abstract-data-setup
3
- description: Set up the Abstract Data Documentation Theme (built on Astro Starlight) for a Python project. Detect source code, audit docstring coverage, sniff docstring style (Google/NumPy/Sphinx), ask configuration questions (modules, motion, credit, version), wire up config files (scripts/python-autodoc.json, astro.config.mjs sidebar + plugin options, package.json scripts), and optionally install a docstring-coverage pre-commit hook in the source project. Use when the user says "set up docs", "configure docs", "wire up Python autodoc", "scan my project for docs", "set up Abstract Data docs", "add API reference", "audit docstrings", or similar phrases inside a docs project that uses @abstractdata/starlight-theme (the npm package name; product is the Abstract Data Documentation Theme).
3
+ description: Set up the Abstract Data Documentation Theme (built on Astro Starlight) for a project. Detect source code across stacks (Python, TypeScript, Next.js, TanStack, OpenAPI, Prisma, Drizzle), audit docstring coverage for Python, sniff docstring style (Google/NumPy/Sphinx), detect or pick a logo asset, ask configuration questions (modules/entry points, motion, credit, version), wire up config files (scripts/python-autodoc.json, scripts/ts-autodoc.json, astro.config.mjs sidebar + plugin options, package.json scripts), and optionally install a docstring-coverage pre-commit hook. Use when the user says "set up docs", "configure docs", "wire up Python autodoc", "wire up TypeScript autodoc", "scan my project for docs", "set up Abstract Data docs", "add API reference", "audit docstrings", or similar phrases inside a docs project that uses @abstractdata/starlight-theme (the npm package name; product is the Abstract Data Documentation Theme).
4
4
  ---
5
5
 
6
6
  # Abstract Data Documentation Theme — Setup
7
7
 
8
- Bootstrap the Abstract Data Documentation Theme — the branded docs system Abstract Data uses across client projects, built on Astro Starlight and shipped as the npm package `@abstractdata/starlight-theme`. Round 1.5 covers Python projects with docstring-coverage and style awareness. Future rounds will add TypeScript, Next.js, TanStack, OpenAPI.
8
+ Bootstrap the Abstract Data Documentation Theme — the branded docs system Abstract Data uses across client projects, built on Astro Starlight and shipped as the npm package `@abstractdata/starlight-theme`. Round 2 covers Python and TypeScript autodoc with full automation, plus detection-and-recipe handling for Next.js, TanStack Router, OpenAPI, Prisma, and Drizzle.
9
9
 
10
10
  ## When to invoke
11
11
 
12
- Run this skill when:
12
+ Run this skill when the user says "set up docs", "configure docs", "wire up Python autodoc", "wire up TypeScript autodoc", "scan my project for docs", "audit docstrings", or similar inside a project that has `@abstractdata/starlight-theme` in its `package.json`. If the cwd doesn't have that dep, stop and point them at `bun create @abstractdata/docs`.
13
13
 
14
- - The user says "set up docs", "configure docs", "wire up Python autodoc", "scan my project for docs", "audit docstrings", or similar.
15
- - The cwd has `@abstractdata/starlight-theme` in `dependencies` or `devDependencies` of `package.json`.
14
+ ## Workflow
16
15
 
17
- If the cwd doesn't have that dep, stop and tell the user this skill only runs in Abstract Data documentation projects (point them at `bun create @abstractdata/docs`).
18
-
19
- ## Workflow (11 phases)
20
-
21
- Use `AskUserQuestion` for every choice — never assume.
16
+ Use interactive prompts for every choice never assume.
22
17
 
23
18
  ### Phase 1 — Confirm context
24
19
 
25
20
  Read `package.json`. Verify `@abstractdata/starlight-theme` is in deps; verify `astro.config.mjs` and `src/content/docs/` exist. Stop with a clear message if any check fails. Don't ask the user to confirm — just announce findings and move on.
26
21
 
27
- ### Phase 2 — Locate the source project
22
+ ### Phase 2 — Locate the source project(s)
28
23
 
29
- AskUserQuestion: where does the source project live?
24
+ Ask via interactive prompt: where does the source project live?
30
25
  - "This directory" — docs ARE the source (rare)
31
26
  - "Parent directory (..)" — docs sit inside the source repo
32
27
  - "Sibling directory" — separate repos at the same level
@@ -34,109 +29,269 @@ AskUserQuestion: where does the source project live?
34
29
 
35
30
  Validate the path exists. Reprompt on invalid.
36
31
 
37
- ### Phase 3 — Detect Python signals
32
+ ### Phase 3 — Detect all stack signals
38
33
 
39
- Look for `pyproject.toml`, `setup.py`, `requirements.txt`, `src/<pkg>/__init__.py`, `<pkg>/__init__.py`. If none, exit: "I didn't find Python source at <path>. Round 1 only handles Python projects."
34
+ In the source path, scan for these signals in parallel. Report what you find before asking any per-stack questions.
40
35
 
41
- If found, identify:
42
- - **Package root** (directory with top-level `__init__.py`)
43
- - **Package name** (from `pyproject.toml [project] name`, or directory name)
44
- - **Submodules** (one level deep, exclude dunders, cap at ~30)
36
+ **Python:**
37
+ - `pyproject.toml`, `setup.py`, `requirements.txt`, `Pipfile`
38
+ - `src/<pkg>/__init__.py` or `<pkg>/__init__.py`
45
39
 
46
- ### Phase 4 — Audit docstring coverage
40
+ **TypeScript library:**
41
+ - `tsconfig.json` AND `package.json` with `main`/`exports`/`types` fields
42
+ - `src/index.ts` or similar entry point
47
43
 
48
- For each candidate module, compute the percentage of public callables (functions, methods, classes) that have docstrings.
44
+ **Next.js:**
45
+ - `next.config.{js,mjs,ts}`
46
+ - `app/` directory (App Router) or `pages/` directory (Pages Router)
47
+ - `next` in dependencies
49
48
 
50
- **Preferred tool: `interrogate`.** Check if it's available:
49
+ **TanStack Router / Start:**
50
+ - `@tanstack/react-router`, `@tanstack/react-start`, or `@tanstack/start` in dependencies
51
+ - `src/routes/` directory
52
+ - `src/routeTree.gen.ts` (generated route tree)
51
53
 
52
- ```bash
53
- which interrogate
54
- ```
54
+ **OpenAPI:**
55
+ - `openapi.yaml`, `openapi.json`, `swagger.yaml`, `swagger.json`
56
+ - Files matching `*.openapi.{yaml,json}`
55
57
 
56
- If yes, run:
58
+ **Prisma:**
59
+ - `prisma/schema.prisma`
57
60
 
58
- ```bash
59
- interrogate -v <package_root> --omit-covered-files --output json 2>/dev/null | jq .
61
+ **Drizzle:**
62
+ - `drizzle.config.{ts,js}`
63
+ - Files in a `schema/` directory exporting `pgTable` / `mysqlTable` / `sqliteTable`
64
+
65
+ **Logo asset (in the docs project, not the source):**
66
+ - `src/assets/*.{png,svg,jpg,jpeg,webp}` — anything that looks like a logo (`logo.*`, `*-logo.*`, `brand.*`)
67
+
68
+ Display the detection summary in a table:
69
+
70
+ ```
71
+ Stack Detected Action
72
+ Python yes will offer Python autodoc
73
+ TypeScript yes will offer TypeScript autodoc
74
+ Next.js no —
75
+ TanStack yes recipe-only (no auto-config)
76
+ OpenAPI no —
77
+ Prisma yes recipe-only (no auto-config)
78
+ Drizzle no —
79
+ Logo 1 file will confirm choice
60
80
  ```
61
81
 
62
- If `interrogate` is unavailable, fall back to a quick AST walk via `python3 -c`:
82
+ If no source signals at all exit politely.
83
+
84
+ ### Phase 4 — Python: audit + style (only if Python detected)
85
+
86
+ #### 4a — Audit docstring coverage
87
+
88
+ Preferred tool: `interrogate` (`pipx install pydoc-markdown` first if not installed). Fall back to a Python AST one-liner. Categorize per-module:
89
+ - **≥ 80%** green
90
+ - **50-79%** yellow
91
+ - **< 50%** red
92
+
93
+ Show the table; don't editorialize.
94
+
95
+ #### 4b — Detect docstring style
96
+
97
+ Sample 10–20 docstrings, count distinctive markers (Google `Args:`/`Returns:`, NumPy `Parameters\n----`, Sphinx `:param x:`). Pick the leader if it has ≥60% of markers; otherwise call it "mixed."
98
+
99
+ ### Phase 5 — TypeScript: entry-point detection (only if TS library detected)
100
+
101
+ Read `package.json` `main`/`exports`/`types` fields. Walk `src/` for `index.ts` files. Build a candidate list of entry points (one per public module surface).
102
+
103
+ Common shapes:
104
+ - Single entry: `src/index.ts` → one entry point
105
+ - Multi-entry: `package.json` `exports` lists multiple → one entry per exported subpath
106
+ - Monorepo: each package has its own entry
107
+
108
+ #### 5a — Audit TSDoc coverage
109
+
110
+ Mirror Phase 4a for TypeScript. Run TypeDoc in **validation-only** mode against the chosen entry points:
63
111
 
64
112
  ```bash
65
- python3 -c "
66
- import ast, sys, os
67
- def cov(path):
68
- with open(path) as f:
69
- tree = ast.parse(f.read())
70
- items = [n for n in ast.walk(tree)
71
- if isinstance(n, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef))
72
- and not n.name.startswith('_')]
73
- if not items: return None
74
- have = sum(1 for n in items if ast.get_docstring(n))
75
- return have, len(items)
76
- # walk a directory ...
77
- "
113
+ bunx typedoc \
114
+ --plugin typedoc-plugin-markdown \
115
+ --validation.notDocumented \
116
+ --treatValidationWarningsAsErrors false \
117
+ --emit none \
118
+ <entryPoints>
78
119
  ```
79
120
 
80
- Compute per-module coverage. Categorize:
81
- - **≥ 80%** — green, ready to document
82
- - **50-79%** — yellow, usable but gaps
83
- - **< 50%** — red, autodoc output will be sparse
121
+ Parse the resulting warnings — TypeDoc emits one line per undocumented symbol with `[warning]` prefix. Group by source file and report per-file coverage as a percentage of public exports that have at least one TSDoc block. Use the same color thresholds as the Python audit:
84
122
 
85
- Show the user a table-style report:
123
+ - **≥ 80%** green
124
+ - **50–79%** yellow
125
+ - **< 50%** red
86
126
 
87
- ```
88
- Module Coverage Status
89
- auditkit.config 12/12 100% ✓ green
90
- auditkit.bootstrap 3/3 100% ✓ green
91
- auditkit.modules.ssl 2/11 18% ✗ red — consider adding docstrings first
92
- ```
127
+ If TypeDoc isn't installed yet, fall back to a quick AST sniff: count files in `src/` with `/**` blocks vs total exported declarations. Coarser, but no install required.
93
128
 
94
- Don't editorialize too much just the data. Then move on.
129
+ Show the table; don't editorialize. The result feeds Phase 12 (pre-commit hook offer).
95
130
 
96
- ### Phase 5Detect docstring style
131
+ ### Phase 6Logo detection
97
132
 
98
- Sample 10–20 docstrings across the source tree (e.g., grep for `"""` and read context). Count distinctive markers:
133
+ Scan `src/assets/**/*.{png,svg,jpg,jpeg,webp}` recursively. Build candidate categories:
99
134
 
100
- - **Google**: `^\s+Args:\s*$`, `^\s+Returns:\s*$`, `^\s+Raises:\s*$`, `^\s+Yields:\s*$`
101
- - **NumPy**: `^\s+Parameters\s*\n\s+-+\s*$`, `^\s+Returns\s*\n\s+-+\s*$`
102
- - **Sphinx/reST**: `:param \w+:`, `:returns:`, `:raises \w+:`, `:type \w+:`
135
+ - **Topbar mark candidates**: filename matches `(logo|brand|mark|icon)\.(svg|png|webp)$` (case-insensitive). SVG preferred.
136
+ - **Light/dark pair**: filenames contain `light` or `dark` and otherwise match logo conventions (e.g. `logo-light.svg` + `logo-dark.svg`). Starlight supports both via `logo.light` + `logo.dark`.
137
+ - **Hero candidates**: any image larger than ~80KB or with `hero` / `splash` in the name — usually a bigger variant for the splash page.
138
+ - **Other images**: no logo conventions; treat as miscellaneous.
103
139
 
104
- Whichever style has the highest hit count wins. If the leader is < 60% of total markers, call it "mixed" and warn.
140
+ For each candidate, gather:
141
+ - File size in bytes
142
+ - Format (extension)
143
+ - Whether the filename indicates light/dark intent
105
144
 
106
- Report findings:
145
+ Display a 4-7 line summary table:
107
146
 
108
147
  ```
109
- Docstring style: Google (32 markers, 0 NumPy, 4 Sphinx)
148
+ File Size Format Suggested role
149
+ src/assets/logo.svg 12 KB SVG topbar mark (recommended)
150
+ src/assets/logo-light.svg 12 KB SVG topbar (light mode)
151
+ src/assets/logo-dark.svg 12 KB SVG topbar (dark mode)
152
+ src/assets/hero-mark.png 145 KB PNG splash hero image
110
153
  ```
111
154
 
112
- If mixed, mention that pydoc-markdown will produce inconsistent output until the style is unified, but don't force a decision — proceed with the most common style.
155
+ Branch on what you found:
113
156
 
114
- (Note: pydoc-markdown's CLI doesn't accept processor flags, so the orchestrator can't auto-apply the matching processor. Style detection is informational unless the user opts into a YAML pipeline.)
157
+ - **One mark + light/dark pair** propose using the pair (Starlight handles auto-switching by `data-theme`)
158
+ - **One mark, no pair** → propose using it for both modes
159
+ - **Multiple marks, no clear winner** → multiselect: which for topbar? Which for hero? `multiSelect: true` interactive prompt.
160
+ - **Zero candidates** → ask: "I don't see a logo in `src/assets/`. Drop one in (SVG preferred, ~256x256 minimum), tell me where it is, or skip for now and configure manually later."
115
161
 
116
- ### Phase 6 Recommend modules to document
162
+ Format guidance to surface alongside the prompt:
163
+ - SVG renders crispest at any size; preferred for both topbar and hero.
164
+ - PNG works fine; 256×256 minimum for the topbar (Astro will downscale via the asset pipeline).
165
+ - JPG is fine for hero photos but bad for marks (compression artifacts on edges).
166
+ - Files > 200KB will bloat first-paint; suggest optimizing or using a smaller source.
117
167
 
118
- Show coverage findings. AskUserQuestion (max 4 options, first recommended):
168
+ ### Phase 7 Recommend documentation surfaces
169
+
170
+ For each detected stack, ask whether to wire it up. Stack questions are per-stack, not lumped together.
171
+
172
+ #### Python (if detected)
173
+
174
+ Interactive prompt with up to 4 options:
119
175
  - "Top-level package only" (Recommended)
120
176
  - "All green-coverage modules" (≥80%)
121
- - "Specific submodules I'll pick" → follow up with `multiSelect: true`
122
- - "Everything" (warn about red modules: empty pages)
177
+ - "Specific submodules I'll pick" → multiselect
178
+ - "Everything" (warn about red-coverage modules)
179
+
180
+ #### TypeScript (if detected)
181
+
182
+ Interactive prompt:
183
+ - "Single root entry point (src/index.ts)" (Recommended for libs with one public API)
184
+ - "All paths in package.json `exports`" (Recommended for multi-entry libs)
185
+ - "I'll pick specific entry points" → free-form
186
+
187
+ #### Other detected stacks (Next.js, TanStack, OpenAPI, Prisma, Drizzle)
188
+
189
+ Don't auto-configure. Tell the user the recipe and let them follow up:
190
+
191
+ - **Next.js**: "I detected Next.js. There isn't a standard one-shot route documenter, but you can write a small build script that walks `app/` or `pages/` and emits a `routes.md`. Want me to draft one?"
192
+ - **TanStack Router**: "I detected TanStack Router. Generate a route map by importing `routeTree.gen.ts` and walking it in a build script. Want a starter?"
193
+ - **OpenAPI**: "I detected an OpenAPI spec. Recommend `@astrojs/starlight-openapi` for the cleanest integration. Want me to install it and wire it up?"
194
+ - **Prisma**: "I detected a Prisma schema. Try `prisma-markdown` for schema docs. Want me to add it to dev deps and wire a script?"
195
+ - **Drizzle**: "I detected a Drizzle config. There isn't a mature schema-to-markdown tool yet — most teams write their own walker over the schema exports. Want me to draft a starter?"
196
+
197
+ If the user says yes to any of these, fall back to free-form work — these aren't covered by the main config files.
198
+
199
+ ### Phase 7.5 — Optional Starlight plugins
200
+
201
+ Three plugins are cheap, high-value DX wins for most docs sites. Don't auto-install — surface them as an interactive multi-select prompt with sensible per-project defaults. Skip the prompt entirely if the user has already declined them in a previous run (look for a `.abstractdata-setup.json` marker or for the plugins already being absent + the import already pruned).
202
+
203
+ For each, you decide the default based on signals you've already gathered:
123
204
 
124
- Build the final modules array as fully-qualified names.
205
+ - **`starlight-llms-txt`** emits an `llms.txt` summary at `/llms.txt` (per [llmstxt.org](https://llmstxt.org)) so AI crawlers can ingest the site as plain Markdown rather than parsing rendered HTML. **Default: ON.** No real downside.
206
+ - **`@expressive-code/plugin-package-managers`** *(code-block plugin, not a Starlight plugin)* — auto-renders npm/pnpm/yarn/bun tabs from a single `npm install foo` code block. **Default: ON if** the README, quickstart, or any docs page contains `bun add`, `npm install`, `pnpm add`, or `yarn add`. **Default: OFF otherwise.**
207
+ - **`starlight-image-zoom`** — click-to-zoom on images. **Default: ON if** the docs project has more than ~5 images under `src/assets/` or `src/content/docs/**/*.{png,jpg,svg,webp}` (a heuristic for "this site uses screenshots"). **Default: OFF otherwise.**
125
208
 
126
- ### Phase 7 Gather brand configuration
209
+ Show the user the three options with their suggested defaults pre-checked, and let them un-check / toggle. For each accepted plugin:
127
210
 
128
- Read existing `astro.config.mjs`. If `motion`, `credit`, `version` are already set and the user didn't ask to change them, skip this phase.
211
+ 1. Add to `dependencies` in `package.json`.
212
+ 2. Add the import to `astro.config.mjs`.
213
+ 3. Wire the plugin entry into the `plugins` array (or `expressiveCode.plugins` for the package-managers plugin).
214
+ 4. Tell the user the bun command to run: `bun add <plugin-name>`.
215
+
216
+ Show the resulting diff before writing. Don't run `bun add` yourself — the user does it.
217
+
218
+ ### Phase 8 — Gather brand + contributor-loop configuration
219
+
220
+ Read existing `astro.config.mjs`. If `motion`, `credit`, `version`, `lastUpdated`, and `editLink` are already set and the user hasn't asked to change them, skip this phase.
221
+
222
+ Otherwise, batch into one prompt:
129
223
 
130
- Otherwise, batch into one AskUserQuestion call:
131
224
  1. Motion: full | calm (Recommended)
132
225
  2. Credit: auto | hide
133
- 3. Version chip: show (then ask for string) | omit
226
+ 3. Version chip: show with version string | omit
227
+ 4. **Last-updated timestamps** (Recommended on): renders a "Last updated" footer on each page using `git log`. Requires a git checkout at build time. Set `lastUpdated: true` if yes, omit otherwise.
228
+ 5. **"Edit on GitHub" link** (Recommended on for OSS): renders an Edit link in the footer pointing at the source. Needs a repo URL — derive it from `package.json` `repository.url` or the source-project remote (`git remote get-url origin`). If found, write `editLink: { baseUrl: '<repo>/edit/<default-branch>/' }`; if not, leave the commented-out scaffold in place and tell the user how to fill it in.
229
+
230
+ Both items 4 and 5 are cheap, high-impact contributor-loop wins per the Astro/Starlight best-practices guide — default to enabling them unless the user opts out.
231
+
232
+ ### Phase 9 — Configure logo
233
+
234
+ Two surfaces need updating:
235
+
236
+ **a) Topbar logo — `astro.config.mjs` `starlight.logo`**
237
+
238
+ First, look at what Phase 6 detected. Three branches:
134
239
 
135
- ### Phase 8Write configs
240
+ 1. **Phase 6 found a light/dark pair** (e.g. `logo-light.svg` + `logo-dark.svg`) → use the `{ light, dark }` form. Starlight auto-switches based on `data-theme`. Don't ask which to use as the default both render at the right time.
241
+
242
+ 2. **Phase 6 found a single mark** → use the single-`src` form. Optionally suggest the user create a dark variant later if the mark is colored in a way that won't survive a dark background.
243
+
244
+ 3. **Phase 6 found nothing** → leave the existing commented `// logo: { ... }` block in `astro.config.mjs` and tell the user where to drop a logo file.
245
+
246
+ Then ask one final question (skip if you already know): does the logo include the project name as text/wordmark?
247
+
248
+ - **Yes** (logo + wordmark in one image) → `replacesTitle: true` — Starlight hides the text title and shows just the logo.
249
+ - **No** (just a mark/icon, no text) → `replacesTitle: false` — Starlight shows the mark beside the text title.
250
+
251
+ Then write the config:
252
+
253
+ ```js
254
+ // Single mark
255
+ logo: {
256
+ src: './src/assets/logo.svg',
257
+ replacesTitle: false,
258
+ }
259
+
260
+ // Light/dark pair (preferred when Phase 6 found both files)
261
+ logo: {
262
+ light: './src/assets/logo-light.svg',
263
+ dark: './src/assets/logo-dark.svg',
264
+ replacesTitle: true,
265
+ }
266
+ ```
267
+
268
+ If a `logo:` block already exists in the config, edit it in place — don't add a duplicate. If `logo:` is in a comment or commented-out, uncomment and update.
269
+
270
+ **b) Splash hero image — `src/content/docs/index.mdx` `hero.image.file`**
271
+
272
+ Default Starlight splash hero supports a separate (usually larger) image. Check the existing `index.mdx` frontmatter:
273
+
274
+ ```yaml
275
+ hero:
276
+ image:
277
+ file: ../../assets/hero-mark.png
278
+ alt: <project name>
279
+ ```
280
+
281
+ If a hero candidate was identified in Phase 6, update this path. If the same logo serves both roles, point both at the same file. If the user wants to use the branded `<Hero>` MDX component (richer than the frontmatter hero), point them at the migration guide section that covers it.
282
+
283
+ **Verify after writing:**
284
+
285
+ After both surfaces are updated, encourage the user to run `bun dev` and visually confirm the logo renders correctly in both light and dark modes (toggle from the topbar). Common issues:
286
+ - Logo is white-on-white in light mode → need a dark variant or use the `light`/`dark` pair pattern
287
+ - Logo is way too small/large → adjust the source dimensions or add CSS overrides via `customCss`
288
+ - File path is wrong → relative paths in `astro.config.mjs` are relative to the project root, not the file itself
289
+
290
+ ### Phase 10 — Write configs
136
291
 
137
292
  Show diffs in your reasoning before writing.
138
293
 
139
- **a) `scripts/python-autodoc.json`** resolve searchPath relative to the docs project root. If file exists, merge: keep outputDir, replace searchPath/modules.
294
+ #### a) `scripts/python-autodoc.json` (if Python wired up)
140
295
 
141
296
  ```json
142
297
  {
@@ -146,116 +301,255 @@ Show diffs in your reasoning before writing.
146
301
  }
147
302
  ```
148
303
 
149
- **b) `astro.config.mjs`** two edits:
150
- 1. Ensure sidebar has `{ label: 'API Reference', autogenerate: { directory: 'api' } }`. Don't duplicate.
151
- 2. Update the `abstractData(...)` call's `motion`/`credit`/`version`. Preserve other options.
304
+ #### b) `scripts/ts-autodoc.json` (if TypeScript wired up)
152
305
 
153
- **c) `package.json`** — ensure `scripts["docs:python"]` is `"node scripts/build-python-docs.mjs"`.
306
+ ```json
307
+ {
308
+ "entryPoints": [...],
309
+ "tsconfig": "<relative path>",
310
+ "outputDir": "src/content/docs/api/ts"
311
+ }
312
+ ```
154
313
 
155
- **d) `scripts/build-python-docs.mjs`** — should already exist from the template. If missing, tell the user to scaffold a fresh project via `bun create @abstractdata/docs` and copy it over.
314
+ #### c) `astro.config.mjs`
156
315
 
157
- ### Phase 9 — Optionally run
316
+ Multi-edit:
158
317
 
159
- AskUserQuestion: generate API pages now?
160
- - "Yes, run bun run docs:python" (Recommended)
161
- - "No, I'll run it later"
318
+ 1. Sidebar ensure entries exist for each enabled generator:
319
+ - `{ label: 'Python API', autogenerate: { directory: 'api' } }` — if Python
320
+ - `{ label: 'TypeScript API', autogenerate: { directory: 'api/ts' } }` — if TS
321
+ 2. Plugin call — update `motion`/`credit`/`version` from Phase 8.
322
+ 3. Logo — update `logo.src` from Phase 9.
162
323
 
163
- If yes, invoke via Bash. Pass through any pydoc-markdown install instructions verbatim if missing.
324
+ Don't duplicate sidebar entries. Don't add a second `abstractData(...)` plugin call.
164
325
 
165
- ### Phase 10 — Offer pre-commit hook in source project
326
+ #### d) `package.json`
166
327
 
167
- Only run this phase if Phase 4 found at least one module below 80% coverage. Otherwise skip.
328
+ Add scripts conditionally:
329
+ - `"docs:python": "node scripts/build-python-docs.mjs"` — if Python wired up
330
+ - `"docs:ts": "node scripts/build-ts-docs.mjs"` — if TS wired up
168
331
 
169
- AskUserQuestion:
332
+ Update the `build` script to chain them:
333
+ ```json
334
+ "build": "bun run docs:python && bun run docs:ts && astro check && astro build"
335
+ ```
336
+ (Skip the chains for stacks not enabled.)
337
+
338
+ #### e) Required dev deps for TS
170
339
 
340
+ If TS wired up, add to dev deps:
341
+ ```bash
342
+ bun add -d typedoc typedoc-plugin-markdown
171
343
  ```
172
- Want me to add a docstring-coverage pre-commit hook to your source project at <path>?
173
- - "Yes, install interrogate hook" (Recommended)
174
- - "Yes, but with a lower threshold (60%)" — for projects that need to ramp up
175
- - "No, skip"
344
+
345
+ Tell the user to run this; don't run it yourself.
346
+
347
+ #### f) Tailor `src/content/docs/quickstart.md` to the detected stack
348
+
349
+ The scaffolded `quickstart.md` ships with both Python and TypeScript autodoc subsections wrapped in HTML comment markers:
350
+
351
+ ```html
352
+ <!-- abstract-data-setup:python-autodoc -->
353
+ …Python instructions…
354
+ <!-- /abstract-data-setup:python-autodoc -->
355
+
356
+ <!-- abstract-data-setup:ts-autodoc -->
357
+ …TypeScript instructions…
358
+ <!-- /abstract-data-setup:ts-autodoc -->
176
359
  ```
177
360
 
178
- If yes:
361
+ After you've finalized the stack(s) for this project (Phase 7), edit `quickstart.md` to remove the irrelevant block:
179
362
 
180
- 1. Check for existing `.pre-commit-config.yaml` in the source project root.
181
- 2. If absent, create:
363
+ - **Python only** strip everything between `<!-- abstract-data-setup:ts-autodoc -->` and `<!-- /abstract-data-setup:ts-autodoc -->` (inclusive).
364
+ - **TypeScript only** → strip the Python block similarly.
365
+ - **Both** → leave both blocks; remove only the comment markers themselves so the published page is clean.
366
+ - **Neither** (no autodoc wired up) → strip both blocks plus the "## Add API reference" heading and intro paragraph.
182
367
 
183
- ```yaml
184
- repos:
185
- - repo: https://github.com/econchick/interrogate
186
- rev: 1.7.0
187
- hooks:
188
- - id: interrogate
189
- args: [--fail-under=80, -v, src/]
368
+ This is idempotent: re-runs of the skill check whether the markers still exist before pruning. If the user has already removed the markers (or hand-edited the file), leave it alone — never re-inject content into a customized quickstart.
369
+
370
+ ### Phase 11 — Optionally run generators
371
+
372
+ Per enabled generator, ask: "Generate now? [Yes / No]"
373
+
374
+ - Python → `bun run docs:python`
375
+ - TypeScript → `bun run docs:ts`
376
+
377
+ Pass through any tool-not-installed errors verbatim.
378
+
379
+ ### Phase 11.5 — Offer docs-author dispatch (if generators ran)
380
+
381
+ After generation, scan `src/content/docs/api/` for **thin pages** — auto-generated files whose body (after frontmatter and the auto-rendered H1) is fewer than ~200 bytes, OR pages that consist of just signatures with no descriptive prose. These are the "what the heck is this?" pages — the source's docstrings are too sparse for the mechanical autodoc to produce useful output.
382
+
383
+ If any thin pages are found, surface this to the user:
384
+
385
+ > "I noticed N of the generated API pages are sparse — your source's docstrings are thin. The companion skill `abstract-data-docs-author` reads the source code itself and writes narrative prose to enrich those pages (module overview, usage example from tests, related-modules cross-references). Want me to invoke it now?"
386
+
387
+ If yes: hand off to the `abstract-data-docs-author` skill (Claude Code: load the skill at `.claude/skills/abstract-data-docs-author/SKILL.md`; Cursor: refer to `.cursor/rules/abstract-data-docs-author.mdc`). Pass along the project profile and detected stack info so the docs-author skill doesn't have to re-discover.
388
+
389
+ If no thin pages found, skip this phase silently. Don't push the docs-author skill on a project that doesn't need it.
390
+
391
+ ### Phase 11.7 — Versioned API reference (only if source has 2+ tags)
392
+
393
+ Run `git -C <source-repo> tag --list 'v*' | wc -l` (or equivalent) on the **source** repo (not the docs project). If the result is < 2, skip this phase silently.
394
+
395
+ Otherwise, surface the choice:
396
+
397
+ > "I see your source has N tagged releases. Versioned API reference is supported four ways. Which do you want?"
398
+
399
+ Multi-choice prompt:
400
+
401
+ 1. **Source-driven (Recommended for API-only versioning).** Adds a `versions` array to `python-autodoc.json` / `ts-autodoc.json`. Each rebuild checks out the source repo at each tag (via `git worktree add`), regenerates the API reference per tag into `<outputDir>/<safeTag>/`, and aliases the default version at the un-versioned URL. Cheap, composable, no branches to maintain. The bundled `<VersionPicker>` component renders a topbar dropdown.
402
+ 2. **`starlight-versions` plugin** — opinionated, archives the entire site (guides + API). Pick this only if guides drift between versions too. Pre-1.0; expect rough edges.
403
+ 3. **Branch-per-version** — each major version is a git branch deployed to a subdomain, the main branch's host (Vercel/CF) rewrites `/v2/*` → that subdomain. Best when teams already maintain per-version branches.
404
+ 4. **Single version (no versioning).** Default if the user is unsure. Easy to add versioning later.
405
+
406
+ Default the recommendation to **option 1** when the project has Python or TypeScript autodoc wired (Phases 4/5 ran). Default to **option 2** when the docs project has substantial hand-written guides and the user expects them to differ per version.
407
+
408
+ If the user picks option 1:
409
+
410
+ a. Surface up to the 5 most recent tags as candidates. Ask which to publish — let them deselect noisy point releases. Mark the most recent as `default: true` unless the user picks a different one (e.g. an LTS tag).
411
+
412
+ b. Write the `versions` array into the appropriate autodoc JSON config. Example shape:
413
+
414
+ ```jsonc
415
+ {
416
+ "searchPath": "../../auditkit/src",
417
+ "modules": [...],
418
+ "outputDir": "src/content/docs/api",
419
+ "versions": [
420
+ { "tag": "v0.4.0", "label": "0.4 (latest)", "default": true },
421
+ { "tag": "v0.3.2", "label": "0.3" },
422
+ { "tag": "v0.2.0", "label": "0.2 (legacy)" }
423
+ ]
424
+ }
190
425
  ```
191
426
 
192
- 3. If present, append the interrogate hook to the `repos` array. Don't duplicate if already present.
193
- 4. Add `interrogate` to dev deps:
194
- - `pyproject.toml` — add to `[project.optional-dependencies] dev` if that table exists
195
- - `requirements-dev.txt` — append if it exists
196
- - Otherwise mention to the user that they need to install it manually
197
- 5. Tell the user to run `pre-commit install` in the source project root to activate the hook (don't run it yourself — that's the source repo, not the docs repo, and it modifies their git hooks).
427
+ c. **No override needed.** The `abstractData()` plugin already overrides `SocialIcons` to render `<VersionPicker>` next to the existing chip and social links. As soon as the autodoc orchestrator emits per-version pages with `version:` frontmatter, the picker appears in the topbar automatically — no user-side wiring, no `versions` prop to maintain. The picker walks the docs collection at build time, dedupes by tag, picks up the `versionDefault: true` flag for the default version. The autodoc JSON is the single source of truth.
198
428
 
199
- ### Phase 11 Summary
429
+ If the autodoc base path differs from the default `/api` (e.g. `outputDir: "src/content/docs/api/ts"` for TypeScript-only sites), pass `apiBase` to the plugin so the picker constructs the right URLs:
200
430
 
201
- Print a 6–10 line markdown summary:
431
+ ```js
432
+ starlight({
433
+ plugins: [
434
+ abstractData({
435
+ motion: 'calm',
436
+ apiBase: '/api/ts',
437
+ }),
438
+ ],
439
+ })
440
+ ```
202
441
 
442
+ d. **Verify the docs project's content schema accepts the version frontmatter fields.** Read `src/content.config.ts` and confirm the `docsSchema.extend` zod object includes:
443
+
444
+ ```ts
445
+ version: z.string().optional(),
446
+ versionLabel: z.string().optional(),
447
+ versionDefault: z.boolean().optional(),
203
448
  ```
204
- ## Set up complete
205
-
206
- **Configured for**: <package> at <path>
207
- **Modules**: <count> · <green/yellow/red breakdown>
208
- **Docstring style**: <style> (<confidence>)
209
- **Mode**: <motion> · <credit> · <version chip status>
210
-
211
- **Files updated**:
212
- - scripts/python-autodoc.json
213
- - astro.config.mjs
214
- - package.json
215
- <if hook installed:>
216
- - <source-path>/.pre-commit-config.yaml (added interrogate hook)
217
- - <source-path>/pyproject.toml (added interrogate to dev deps)
218
-
219
- <if Phase 9 ran:>
220
- **Generated**: <count> API pages in src/content/docs/api/
221
-
222
- **Next**:
223
- 1. `bun dev`
224
- 2. Visit /api/ to see the generated pages
225
- 3. Address any red-coverage modules in your source, then re-run `bun run docs:python`
226
- <if hook installed:>
227
- 4. `cd <source-path> && pre-commit install` to activate the docstring hook
449
+
450
+ The `create-docs` template scaffold already ships with these. For projects upgraded via `bunx abstract-data-install-skills`, you'll need to add them — without these optional fields, Zod will reject the autodoc-emitted frontmatter and the build fails with `InvalidContentEntryDataError`.
451
+
452
+ e. Tell the user to run `bun run docs:python` (or `docs:ts`) to populate the per-version directories. The script handles the worktrees automatically.
453
+
454
+ f. **Optional curated override.** If the user wants to hide pre-release tags or reorder the dropdown, they can wire a user-level override of `SocialIcons` that imports `<VersionPicker>` and passes an explicit `versions` prop — that bypasses auto-discovery. Don't recommend this by default; auto-discovery keeps the autodoc JSON as the single source of truth.
455
+
456
+ If the user picks option 2 (`starlight-versions`):
457
+
458
+ - Install: `bun add starlight-versions`
459
+ - Add to `astro.config.mjs` plugins array
460
+ - Run the plugin's CLI to archive the current state
461
+ - Configure `starlight-versions.versions` to match the user's version list
462
+ - Note: this conflicts with option 1 — pick *one*.
463
+
464
+ If the user picks option 3 (branch-per-version):
465
+
466
+ - This is mostly a deployment-platform concern. Suggest the Knip pattern (Vercel rewrites) and link them at [webpro.nl/scraps/versioned-docs-with-starlight-and-vercel](https://webpro.nl/scraps/versioned-docs-with-starlight-and-vercel). Don't try to wire this yourself — too platform-specific.
467
+
468
+ If the user picks option 4 (none): skip silently, leave `versions` field absent from the autodoc config.
469
+
470
+ **Site version vs. API version** they're different. The `version` chip in the theme's plugin call (e.g. `version: 'v1.0.0'`) is the *site's own* marketing version. The `versions` array in autodoc configs is the *documented API's* versions. A site might be at `v1.2.0` while documenting API `v0.4.0` — that's normal, don't conflate them.
471
+
472
+ ### Phase 12 Optional pre-commit hook (per-stack)
473
+
474
+ Fires only if Phase 4a (Python) or Phase 5a (TypeScript) found modules below the 80% coverage threshold.
475
+
476
+ **Python branch** — if Phase 4a found yellow/red modules, offer:
477
+
478
+ - Tool: `interrogate` (lightweight, no project changes beyond the hook entry).
479
+ - Config: append a `[tool.interrogate]` table to `pyproject.toml` setting `fail-under = 80`, `exclude = ["tests"]`, etc.
480
+ - `.pre-commit-config.yaml`: add the `econchick/interrogate` repo with the chosen revision.
481
+
482
+ **TypeScript branch** — if Phase 5a found yellow/red entry points, offer either:
483
+
484
+ - **Local script hook (preferred)**: a one-liner `pre-commit` config that runs the docs build script with `--validation.notDocumented` and fails the commit if any new warnings appear. No extra dependencies beyond `typedoc` (already a dev dep).
485
+
486
+ ```yaml
487
+ # .pre-commit-config.yaml fragment
488
+ - repo: local
489
+ hooks:
490
+ - id: tsdoc-coverage
491
+ name: TSDoc coverage
492
+ entry: bunx typedoc --plugin typedoc-plugin-markdown --validation.notDocumented --treatValidationWarningsAsErrors true --emit none
493
+ language: system
494
+ types: [ts]
495
+ pass_filenames: false
496
+ ```
497
+
498
+ - **`tsdoc-coverage` package** (if the user prefers a dedicated tool): npm install `tsdoc-coverage` as a dev dep and wire it as the hook entry instead. Threshold defaults to 80% to match the Python side.
499
+
500
+ In both stacks: show the user the exact config diff before writing. The pre-commit hook lives in the **source repo**, not the docs repo — extra caution since it's a different project.
501
+
502
+ ### Phase 12.5 — Confirm `starlight-links-validator` is wired
503
+
504
+ The template ships with `starlight-links-validator` already installed and registered as a Starlight plugin. Verify both during this phase:
505
+
506
+ 1. Read the docs project's `package.json` — confirm `starlight-links-validator` is in `dependencies` (or `devDependencies`).
507
+ 2. Read `astro.config.mjs` — confirm the plugin is referenced inside `plugins: [...]` on the `starlight(...)` call.
508
+ 3. Read the docs project's CI workflow (`.github/workflows/*.yml` or equivalent) — confirm `bun run build` (or `astro build`) runs on PRs. The links validator runs as part of the build, so a build-on-PR workflow is enough; no separate step needed.
509
+
510
+ If any of those three pieces are missing, surface the gap and offer to add it. The plugin's failure mode is "fail the build on any broken internal link" — exactly what you want for CI.
511
+
512
+ For migrating projects (running `bunx abstract-data-install-skills` rather than scaffolding via `bun create @abstractdata/docs`), the plugin will not be installed automatically. Tell the user:
513
+
514
+ ```bash
515
+ bun add starlight-links-validator
228
516
  ```
229
517
 
518
+ then add `starlightLinksValidator()` to the `plugins` array in `astro.config.mjs`. Show the diff.
519
+
520
+ ### Phase 13 — Summary
521
+
522
+ 6–10 line markdown summary covering: detected stacks, what got wired up per stack, logo update, mode (motion/credit/version), files updated, generated counts (if Phase 11 ran), next steps.
523
+
230
524
  ## Idempotency
231
525
 
232
526
  - Don't duplicate sidebar entries — check before adding.
233
- - Don't append to `modules` array — replace cleanly.
527
+ - Don't append to `modules`/`entryPoints` arrays — replace cleanly.
234
528
  - Don't add a second `abstractData(...)` call — update the existing one.
235
- - Don't add a second interrogate hook to `.pre-commit-config.yaml` — check first.
236
529
  - Don't overwrite content under `src/content/docs/` (only `api/` pages, regenerated by the script).
530
+ - Don't add a second logo line — replace.
237
531
 
238
532
  ## Out of scope (this round)
239
533
 
240
- - TypeScript/TypeDoc autodoc
241
- - Next.js / TanStack / OpenAPI / Prisma / Drizzle
242
- - Architecture diagrams
243
- - README/CHANGELOG/ADR import
244
- - Forcing the docs build to fail on coverage drop (deliberate — coverage policy belongs to the source project's pre-commit hook, not the docs build)
245
- - Auto-applying a pydoc-markdown processor pipeline based on detected style (CLI doesn't support it; would require switching to YAML config)
534
+ - TanStack route detection auto-config (recipe-only)
535
+ - Next.js route map auto-config (recipe-only)
536
+ - Prisma schema-doc auto-config (recipe-only)
537
+ - Drizzle schema-doc auto-config (recipe-only — no mature tooling)
538
+ - README/CHANGELOG/ADR auto-import into the sidebar
246
539
 
247
540
  ## Files this skill reads / writes
248
541
 
249
- **Reads:** docs project's `package.json`, `astro.config.mjs`; source project's `pyproject.toml`, `setup.py`, source tree, existing `.pre-commit-config.yaml`.
542
+ **Reads (docs project):** `package.json`, `astro.config.mjs`, `src/assets/`.
543
+ **Reads (source project):** `pyproject.toml`, `setup.py`, source tree, `tsconfig.json`, `next.config.*`, dependency manifests, schema files, OpenAPI specs.
250
544
 
251
- **Writes (docs project):** `scripts/python-autodoc.json`, `astro.config.mjs` (edits), `package.json` (scripts only).
545
+ **Writes (docs project):** `scripts/python-autodoc.json`, `scripts/ts-autodoc.json`, `astro.config.mjs` (edits), `package.json` (scripts only).
252
546
 
253
- **Writes (source project, only with Phase 10 consent):** `.pre-commit-config.yaml`, `pyproject.toml` (dev deps section), `requirements-dev.txt`.
547
+ **Writes (source project, with explicit pre-commit consent only):** `.pre-commit-config.yaml`, `pyproject.toml` (dev deps section), `requirements-dev.txt`, or `package.json` (TS dev deps for `tsdoc-coverage` if chosen).
254
548
 
255
549
  ## Notes for the agent
256
550
 
257
551
  - Be conservative with edits. Show diffs in your reasoning before writing.
258
- - Use `Edit` for in-place updates. Use `Write` for `python-autodoc.json` (full replace).
259
- - Phase 10 modifies a different repo than the docs project extra caution. Show the user exact diffs before applying.
260
- - If interrogate isn't installed in the source's Python env, the audit falls back to AST. Note in the summary that interrogate would give richer reports.
552
+ - Phase 12 modifies a different repo than the docs project — extra caution.
553
+ - For TypeScript: TypeDoc requires `typescript` AND `typedoc` AND `typedoc-plugin-markdown`. If any are missing, the orchestrator will tell the user via the script output. Don't try to install them yourself unless the user explicitly asks.
554
+ - For OpenAPI: prefer `@astrojs/starlight-openapi` (mature plugin) over building from scratch.
261
555
  - Keep conversation tight: detection in 1–3 sentences, audit table 5–8 lines, questions one round at a time, summary 6–10 lines.