refactor(prompts): unify src/lib/insights/prompt*.ts into src/lib/ai/prompts/

Pre-v1.4.41 prompts lived in two homes — `src/lib/ai/prompts/` (per-
metric system prompts + safety contracts) and `src/lib/insights/prompt
*.ts` (user-prompt builder + comparison snapshot + the `compactSections`
helper). A new reader could not tell from filenames which file to
extend; both directories looked equally authoritative. Audit rec #3
flagged the split as the only undiscoverable seam in the AI layer.

Move both files into `src/lib/ai/prompts/`:
  - `lib/insights/prompt.ts` → `lib/ai/prompts/insight-system-prompt.ts`
  - `lib/insights/prompt-compact.ts` → `lib/ai/prompts/compact-sections.ts`
  - co-located tests follow

Three importers updated: `app/api/insights/generate/route.ts`,
`lib/ai/coach/snapshot.ts`, the generate route test (the
`vi.mock('@/lib/insights/prompt')` path moved too). Prompts now have
ONE home and ONE mental model.
This commit is contained in:
Marc-André Bombeck committed 2026-05-21 17:14:01 +02:00
1 parent d0bdc4b8d1
commit 8a56f48259
16 files changed
+473 -613

No files matched your search

+11 -8
View File
@@ -29,12 +29,15 @@ jobs:
- run: pnpm db:generate
# v1.4.40 W-INFRA — fail the build when knip surfaces a new dead
# module, an unused production dependency, an unused devDependency,
# or an unlisted binary. Unused exports + types are intentionally
# left informational while the existing surface is cleaned wave by
# wave (487 exports / 52 types on the v1.4.40 baseline). The
# baseline carve-outs live in `knip.json` under `ignore` +
# `ignoreDependencies` + `ignoreBinaries` with the rationale
# captured in `.planning/phase-W-INFRA-v1440-report.md`.
# v1.4.41 W-PROCESS-DOCS — exports + types tier staged for
# promotion to enforcing. The W-SIMPLIFIER and W-INSIGHTS-HOT
# cleanup waves have not yet landed on develop at the time this
# comment was written (48 unused exports + 52 unused exported
# types still in the tree), so the gate remains scoped to
# files,dependencies,binaries,unlisted. Once those cleanup waves
# merge and `pnpm knip --reporter compact` reports zero unused
# exports + zero unused types, drop the `--include` flag below
# to flip exports + types to enforcing. See
# `.planning/phase-W-PROCESS-DOCS-v1441-report.md` for the
# promotion checklist and the rollback path.
- run: pnpm knip --reporter compact --include files,dependencies,binaries,unlisted