From 6e0f59c62b6ab04352b38d1bd2c34ac501f47f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Smoli=C5=84ski?= Date: Thu, 22 Oct 2026 17:06:52 +0200 Subject: [PATCH] Docs: reconcile agent, developer and module docs with the code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - AGENT.md, skills, PROGRAMISTA, vibe, README and module pages checked against src/ and package.json; every mismatch fixed (consent/analytics loading, revalidation scope, generateStaticParams, construction gating, Turnstile fail modes, email/Graph, MCP, i18n, links, slug, hooks, ...) - New pages: frontend.md, media.md, integrations.md; docs/README.md now indexes every page - Main rule (plugin helps, never limits) at the top of AGENT.md, PROGRAMISTA.md, docs/README.md, README and the setup/plugin-gap skills; module pages gain a "Wyłączenie, nadpisanie, rozszerzenie" section - README/PROGRAMISTA: stop telling projects to install packages ipal-kit already depends on; peer table; publish flow matches prepublishOnly - ipal-skills: refuse --dest without a value or pointing at the project root (previously could delete ipal-* folders in cwd) - docsConsistency: option keys, IPAL_* env names, relative links, README index, AGENT.md section refs, skill frontmatter, frontend.md helper keys, no `pnpm add` of own dependencies Co-Authored-By: Claude Opus 5.5 --- README.md | 52 +++- bin/ipal-skills.mjs | 12 +- docs/README.md | 17 +- docs/accessibility.md | 28 ++- docs/agent/AGENT.md | 87 +++++-- .../skills/ipal-block/resources/kod-sekcji.md | 5 +- docs/agent/skills/ipal-collection/SKILL.md | 3 +- docs/agent/skills/ipal-consent-check/SKILL.md | 17 +- .../scripts/cookie-scan.mjs | 2 + docs/agent/skills/ipal-debug/SKILL.md | 4 +- docs/agent/skills/ipal-form/SKILL.md | 11 +- docs/agent/skills/ipal-locale-add/SKILL.md | 3 +- .../agent/skills/ipal-migrate-fields/SKILL.md | 11 +- .../migrate-block-fields.template.ts | 5 +- docs/agent/skills/ipal-nav/SKILL.md | 5 +- .../ipal-nav/resources/kod-nawigacji.md | 14 +- docs/agent/skills/ipal-plugin-gap/SKILL.md | 9 + docs/agent/skills/ipal-setup/SKILL.md | 9 +- .../resources/seed-content.template.ts | 15 +- docs/agent/skills/ipal-upgrade/SKILL.md | 6 +- docs/analytics.md | 231 +++++------------- docs/blocks.md | 23 +- docs/consent.md | 109 +++++++-- docs/construction.md | 22 +- docs/content.md | 108 ++++++-- docs/deployment.md | 103 +++++--- docs/dev/PROGRAMISTA.md | 97 +++++--- docs/dev/vibe.md | 12 +- docs/email.md | 102 +++++--- docs/env.md | 43 +++- docs/frontend.md | 166 +++++++++++++ docs/gtm-meta-pixel.md | 35 ++- docs/hooks.md | 85 ++++++- docs/i18n.md | 61 ++++- docs/integrations.md | 77 ++++++ docs/links.md | 35 ++- docs/mcp.md | 55 ++++- docs/media.md | 151 ++++++++++++ docs/notifications.md | 19 +- docs/pages.md | 51 +++- docs/payload-helpers.md | 32 ++- docs/richtext.md | 10 +- docs/slug.md | 28 ++- docs/stats.md | 37 ++- docs/storage.md | 150 +++--------- docs/theme.md | 12 + docs/turnstile.md | 66 ++++- docs/white-label.md | 27 +- test/docsConsistency.test.ts | 79 +++++- 49 files changed, 1736 insertions(+), 605 deletions(-) create mode 100644 docs/frontend.md create mode 100644 docs/integrations.md create mode 100644 docs/media.md diff --git a/README.md b/README.md index c9d2a75..cd38d57 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,12 @@ SEO (metadata, canonical, sitemap, robots), forms (Turnstile, rate limiting, validation), consent management (consent mode), analytics (GA4/GTM), and a blog/archive system (collections under an archive page, listing, pagination). +**Principle:** ipal-kit helps projects, never limits them — every module can be +turned off on its own, every default (access, fields, hooks, labels, routes, +collections, globals) can be overridden and the project's config wins, and the +building blocks are exported, not only the finished features. Where the code +doesn't meet this yet, the module's doc says so. + **Repository:** https://git.intecion.net/IntecionSoftware/ipal-kit --- @@ -59,17 +65,35 @@ plugin development. ## Finish setting up your project -The plugin doesn't pull in the dependencies it shares with Payload — add them -yourself, in a version matching your Payload: +`nodemailer`, `lucide-react`, `slugify` and `server-only` are regular +`dependencies` of the plugin — they install with it; don't add them yourself. + +What you provide are the **peer dependencies** — packages the plugin shares with +your project — in a version matching your Payload: + +| Peer | Range | Notes | +|---|---|---| +| `payload`, `@payloadcms/next`, `@payloadcms/ui`, `@payloadcms/richtext-lexical` | `^3.90.2` | already in a `create-payload-app` project | +| `next`, `react` | `>=15`, `^19.0.0` | already in a `create-payload-app` project | +| `@payloadcms/plugin-seo`, `@payloadcms/plugin-form-builder` | `^3.90.2` | **add these** | +| `@clocklimited/payload-2fa` | `^3.0.0-0` | optional peer, but **needed by default**: 2FA is enforced and `ipalKit()` throws at startup unless you pass `twoFactor: { issuer, plugin: payloadTotp }` (or opt out with `twoFactor: false`) | +| `@payloadcms/storage-s3` | `^3.90.2` | optional — only when media go to Cloudflare R2 ([docs/storage.md](./docs/storage.md)) | ```bash pnpm add @payloadcms/plugin-seo@3.90.2 @payloadcms/plugin-form-builder@3.90.2 \ - nodemailer lucide-react slugify server-only + @clocklimited/payload-2fa +pnpm add @payloadcms/storage-s3@3.90.2 # only with R2 media ``` -> **Match `lucide-react` to the plugin.** The plugin uses `lucide-react@^0.400.0`. -> If your project pulls a different major (e.g. `1.x`), you end up with two copies -> and confusing type errors. Pin your project to the same range. +Keep every `@payloadcms/*` at exactly the same version as `payload` +(`pnpm.overrides` — see PROGRAMISTA.md §1). Upload optimization and image +placeholders also use the `sharp` you pass to `buildConfig({ sharp })` +(standard in a `create-payload-app` project). + +> **`lucide-react` comes with the plugin, at `^0.400.0`.** For a `0.x` version +> the caret means **`0.400.x` only** — not "0.400 or newer". If your project also +> uses `lucide-react` at another version (e.g. `0.5xx` or `1.x`), you end up with two +> copies and confusing type errors. Pin your project to `~0.400.0` too. From here, the guide takes over: **[docs/dev/PROGRAMISTA.md](./docs/dev/PROGRAMISTA.md)** — from an empty project to a working site. @@ -96,14 +120,19 @@ scope `write:package`. Put it in the `GITEA_TOKEN` env var. | Linux / Ubuntu | `~/.npmrc` | | Windows | `%USERPROFILE%\.npmrc` | -Then build and publish: +Then version and publish (commit your changes first — `npm version` needs a +clean working tree): ```bash -pnpm clean && pnpm build -npm version patch # 1.0.0 → 1.0.1 -npm publish +npm version patch # 1.0.0 → 1.0.1 (commit + tag) +npm publish # prepublishOnly runs: pnpm clean && pnpm build && pnpm test:int +git push && git push --tags ``` +`publishConfig.registry` in `package.json` already points at the Gitea registry, +so `npm publish` needs no `--registry` flag. A failing build or test aborts the +publish. + Full checklist and troubleshooting: **[docs/dev/PROGRAMISTA.md §8](./docs/dev/PROGRAMISTA.md)**. --- @@ -125,7 +154,8 @@ Everything lives in the **[docs/](./docs)** directory. To get started: |---|---| | `404` on `pnpm add @intecion/...` | the `@intecion:registry` line is missing from `.npmrc` — the install went to public npm instead of Gitea | | `Could not find the module … in the React Client Manifest` | installed from git, not the registry — reinstall from the registry (clean path) | -| two versions of `lucide-react` | your project pins a different major than the plugin's `^0.400.0` — align them | +| two versions of `lucide-react` | your project uses a `lucide-react` outside the plugin's `^0.400.0` (= `0.400.x`) — align them | +| `[ipal] 2FA is enforced but no 2FA plugin was injected` | install `@clocklimited/payload-2fa` and pass `twoFactor: { issuer, plugin: payloadTotp }` | | `missing secret key … to secure Payload` | `PAYLOAD_SECRET` isn't set in the runtime environment (not a plugin issue) | If you get stuck, see **[docs/dev/PROGRAMISTA.md](./docs/dev/PROGRAMISTA.md)** or message the diff --git a/bin/ipal-skills.mjs b/bin/ipal-skills.mjs index cc47f8c..3e9155b 100755 --- a/bin/ipal-skills.mjs +++ b/bin/ipal-skills.mjs @@ -17,7 +17,17 @@ if (args.includes('--help') || args.includes('-h')) { } const dryRun = args.includes('--dry-run') const destArg = args.indexOf('--dest') -const dest = resolve(process.cwd(), destArg >= 0 ? args[destArg + 1] ?? '' : '.agents/skills') +const destValue = destArg >= 0 ? args[destArg + 1] : '.agents/skills' +// A missing value would resolve to cwd and remove every ipal-* folder there. +if (!destValue || destValue.startsWith('-')) { + console.error('ipal-skills: --dest needs a directory, e.g. --dest .claude/skills') + process.exit(1) +} +const dest = resolve(process.cwd(), destValue) +if (dest === resolve(process.cwd())) { + console.error('ipal-skills: --dest must be a subdirectory, not the project root') + process.exit(1) +} const pkgRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..') const src = join(pkgRoot, 'docs', 'agent', 'skills') diff --git a/docs/README.md b/docs/README.md index 8f7595f..025dd1b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,10 +1,16 @@ # Dokumentacja @intecion/ipal-kit +**Zasada nadrzędna:** ipal-kit to plugin — pomaga projektom, nigdy ich nie ogranicza. +Każdy moduł da się wyłączyć osobno, każdą wartość domyślną nadpisać (konfiguracja +projektu wygrywa), bezpieczne ustawienia domyślne mają opcję poluzowania, a plugin +eksportuje klocki (helpery, buildery, hooki), nie tylko gotowe funkcje. Każda strona +modułu ma sekcję „Wyłączenie, nadpisanie, rozszerzenie” — opisuje stan obecnego kodu. + | Kim jesteś | Czytaj | |---|---| | **Agent AI** pracujący w projekcie | [AGENT.md](./agent/AGENT.md) — reguły, struktura, budowa sekcji, kontrole przed „gotowe” | -| **Agent AI — skille** | [agent/skills/](./agent/skills) — 14 skilli `ipal-*` dla Antigravity/Claude Code, w tym `ipal-site` (strona od briefu do raportu) i skrypty kontrolne (kopiowane do projektu: `pnpm ipal:skills`, AGENT.md §14) | -| **Programista** | [PROGRAMISTA.md](./dev/PROGRAMISTA.md) — instalacja, nowy projekt, env, wdrożenie, aktualizacja, publikacja pluginu, Gitea | +| **Agent AI — skille** | [agent/skills/](./agent/skills) — 14 skilli `ipal-*` dla Antigravity/Claude Code, w tym `ipal-site` (strona od briefu do raportu) i skrypty kontrolne (kopiowane do projektu: `pnpm exec ipal-skills`, AGENT.md §14) | +| **Programista** | [PROGRAMISTA.md](./dev/PROGRAMISTA.md) — instalacja, nowy projekt, env, wdrożenie, aktualizacja, publikacja pluginu, Gitea; wdrożenie i health check: [deployment.md](./deployment.md) | | **Osoba prowadząca agenta AI** | [vibe.md](./dev/vibe.md) — tryb autonomiczny (`/ipal-site`) i gotowe polecenia krok po kroku | Szczegóły API — jeden plik na moduł: @@ -18,12 +24,17 @@ Szczegóły API — jeden plik na moduł: | Zgoda cookies, baner, okno ustawień (w pasku / modal / duże ze szczegółami ciasteczek) | [consent.md](./consent.md) | | Strona w budowie — blokada podstron z popupem (narzędzie deweloperskie) | [construction.md](./construction.md) | | Routing, archiwa, redirecty, Markdown, wyszukiwarka | [content.md](./content.md) | +| Front strony: `createContentHelpers` (`@/lib/content`), `createPageRoute`, `SiteProviders` | [frontend.md](./frontend.md) | +| Wdrożenie, zmienne produkcyjne, health check | [deployment.md](./deployment.md) | | Email SMTP / Graph | [email.md](./email.md) | | Walidacja env | [env.md](./env.md) | | Formularze, useForm, honeypot | [forms.md](./forms.md) | +| GA4 + Meta Pixel przez GTM (zdarzenia formularzy) | [gtm-meta-pixel.md](./gtm-meta-pixel.md) | | Hooki | [hooks.md](./hooks.md) | | i18n, proxy, przełącznik języka | [i18n.md](./i18n.md) | +| Integracje (global `site-integrations`, statusy, test e-maila) | [integrations.md](./integrations.md) | | Linki / CTA: buildLinkField, buildLinksField, resolveLinkHref, rowLabel | [links.md](./links.md) | +| Media: kolekcja, nazwy plików, optymalizacja, placeholdery, `mediaImageProps` | [media.md](./media.md) | | Serwer MCP strony | [mcp.md](./mcp.md) | | Komunikaty formularzy | [notifications.md](./notifications.md) | | Strony systemowe, 404, generateStaticParams | [pages.md](./pages.md) | @@ -34,7 +45,7 @@ Szczegóły API — jeden plik na moduł: | Statystyki w panelu (bez cookies; historia odwiedzającego za zgodą) | [stats.md](./stats.md) | | Auto-slug | [slug.md](./slug.md) | | Motyw jasny / ciemny, przełącznik | [theme.md](./theme.md) | -| Media, R2 | [storage.md](./storage.md) | +| R2, `buildImagesConfig`, `MediaPreconnect`, `YouTubeEmbed` | [storage.md](./storage.md) | | Turnstile | [turnstile.md](./turnstile.md) | | White-label panelu | [white-label.md](./white-label.md) | diff --git a/docs/accessibility.md b/docs/accessibility.md index 9ac5c20..b020275 100644 --- a/docs/accessibility.md +++ b/docs/accessibility.md @@ -162,6 +162,23 @@ return ... Provider i tak re-aplikuje na kliencie i synchronizuje. To tylko eliminuje flash. +### Stan i atrybuty (`A11yState`) + +Cookie `a11y-prefs` (`A11Y_COOKIE`, JSON, `path=/`, `max-age` 1 rok, `samesite=lax`). +Helpery `A11Y_COOKIE`, `A11Y_DEFAULT`, `parseA11y`, `serializeA11y`, `a11yAttributes` +są w `@intecion/ipal-kit` (nie w `/client`). `A11yState` jako typ jest w obu entry. + +| Klucz stanu | Wartości | Atrybut na `` (brak = domyślne) | +|---|---|---| +| `textSize` | `0`–`3` | `data-a11y-text="1..3"` | +| `lineHeight` | `0`–`2` | `data-a11y-line="1..2"` | +| `contrast` | `'default' \| 'high' \| 'inverted'` | `data-a11y-contrast="high\|inverted"` | +| `grayscale` | boolean | `data-a11y-grayscale="on"` | +| `underlineLinks` | boolean | `data-a11y-underline="on"` | +| `readableFont` | boolean | `data-a11y-font="readable"` | +| `reduceMotion` | boolean | `data-a11y-motion="reduce"` | +| `bigCursor` | boolean | `data-a11y-cursor="big"` | + --- ## 4. Osobny przycisk otwierający (opcjonalnie) @@ -190,4 +207,13 @@ to **opcja, nie obowiązek** — dodawaj gdy klient wymaga, nie z automatu. Gdy dodajesz: widget sam w sobie NIE czyni strony w pełni dostępną — to pomoc dla użytkownika. Pełna dostępność to też semantyczny HTML, alt teksty, nawigacja klawiaturą, kontrast bazowy. Widget uzupełnia, nie zastępuje. Nie sprzedawaj -klientowi „mamy widget = jesteśmy zgodni z WCAG". Patrz PROGRAMISTA.md §5. +klientowi „mamy widget = jesteśmy zgodni z WCAG". Patrz [dev/PROGRAMISTA.md](dev/PROGRAMISTA.md) §5. + +## Wyłączenie, nadpisanie, rozszerzenie + +- **Wyłączenie:** moduł jest opt-in — bez `AccessibilityProvider` / `AccessibilityWidget` nic się nie dzieje + (brak opcji w `ipalKit`, brak pól w panelu). +- **Nadpisanie:** `classNames` i `texts` widgetu; cały wygląd efektów to CSS projektu. +- **Rozszerzenie:** własny UI na `useAccessibility()` (`state`, `set`, `reset`); SSR helpery + `parseA11y` / `a11yAttributes` / `serializeA11y` / `A11Y_DEFAULT`. Zestawu opcji (`A11yState`) obecnie + nie da się rozszerzyć bez zmian w pluginie. diff --git a/docs/agent/AGENT.md b/docs/agent/AGENT.md index b8b49e0..d4b8999 100644 --- a/docs/agent/AGENT.md +++ b/docs/agent/AGENT.md @@ -14,6 +14,22 @@ --- +## Zasada nadrzędna — plugin pomaga, nie ogranicza + +ipal-kit jest pluginem: pomaga projektowi, nigdy go nie ogranicza. Każdy moduł da się +wyłączyć osobno; każdy domyślny element (reguły dostępu, pola, hooki, etykiety, trasy, +kolekcje, globale) da się nadpisać i **wygrywa konfiguracja projektu**; bezpieczne +ustawienia domyślne mają opcję poluzowania/rozszerzenia; plugin eksportuje klocki +(helpery, buildery, hooki), nie tylko gotowe funkcje; nie wymusza zależności, trasy, UI +ani kształtu danych tam, gdzie wystarczy opcja albo eksportowany klocek. + +**W praktyce:** zanim napiszesz coś od zera albo zaczniesz walczyć z pluginem — znajdź +opcję lub eksportowany builder (docs modułu §12, typy w `dist/**/*.d.ts`). Brakuje jej → +**ipal-plugin-gap** (raport + oznaczone obejście w kodzie projektu), nigdy łatanie +`node_modules` ani fork pakietu. + +--- + ## 0. KOMPAS (jeśli zapamiętasz tylko to) 1. **ipal-kit jest obowiązkowy.** Funkcja, którą plugin ma, idzie przez plugin. @@ -38,6 +54,15 @@ MCP), R2, Turnstile, formularze z buildera. `ipal-audit` sprawdza, czy jest wpięty, `ipal-seo-check` — czy działa. Nie ma „zrobię później”. +**Jak dodać…** (szczegóły w skillu z §14) +| Co | Jak | +|---|---| +| stronę | w panelu: Pages + bloki, zero kodu (§5.1) | +| sekcję (blok) | `src/blocks//config.ts` + `Component.tsx`, wpis w `blocks/registry.ts`, blok w polu `layout` Pages → `pnpm generate:types` (+ `pnpm payload generate:importmap` przy `rowLabel`) — **ipal-block** | +| formularz | panel Forms (builder) z seeda `scripts/seed-form-*.ts`, blok z ``, wysyłka `sendForm` — **ipal-form** | +| język | `i18n.config.ts` (jedyne miejsce) + migracja Postgres + treść w nowym języku — **ipal-locale-add** | +| kolekcję z URL-ami | `content: { collections: [...] }` w `ipalKit` i `createContentHelpers` (§5.4) — **ipal-collection** | + --- ## 0b. OBOWIĄZKOWY KOMPLET — każda strona, bez wyjątku @@ -63,7 +88,7 @@ strona), **P** = test w panelu. Pełny kod: PROGRAMISTA.md §2. | 9 | **Media / R2 / szybkość** | `Media` z `focalPoint`, `normalizeFilenameHook`, `buildOptimizeUploadHook`, `buildMediaPlaceholderHook` + pole; **zawsze** `buildR2Storage(['media'], { s3Storage })` + `@payloadcms/storage-s3`; `R2_*` w `.env.example`; ``; `images: buildImagesConfig()` i `buildUploadSecurityHeaders()` w `next.config.ts`; `` projektu przez `mediaImageProps`/`videoProps` (§6.11b) | `buildR2Storage`, `mediaImageProps`, `videoProps`, `buildImagesConfig` | A, S | | 10 | **Formularze** | każdy formularz z **seeda** (`scripts/seed-form-*.ts`: pola, potwierdzenie, mail do firmy **i** potwierdzenie do klienta, każdy język); blok z `` + `formClasses.ts` (wygląd, raz); `actions.ts` = `createSubmitAction({ getCachedPayload, headers })`; `forms: {…}` w `ipalKit`; `email: mailAdapter()` | `RenderForm` (`/rsc`), `createSubmitAction`, `mailAdapter` | A, P | | 11 | **Turnstile** | `` w `[locale]/layout.tsx` (wpina `TurnstileProvider` z kluczem z panelu); widget renderuje `RenderForm`; klucze w Site Integrations | `SiteProviders`, `getTurnstileConfig`, `TurnstileProvider` | A, P | -| 12 | Zgoda + analityka | `}>` (ConsentProvider, baner, CookieButton, Analytics w dobrej kolejności); tryb okna ustawień (`settings`: `inline` / `modal` / `detailed`) wg designu, brief milczy → `detailed`, decyzja do „Ustaleń projektu”; ID narzędzi w panelu; lista ciasteczek ze skanu (cookie-scan → import) — zasila `` na stronie polityki **i** listy w oknie `detailed`; Cookie Settings → Detail labels w każdym języku | consent.md, analytics.md | A, `ipal-consent-check` | +| 12 | Zgoda + analityka | `ipalKit({ consentLog: true })` (bez tego endpointu `/api/ipal/consent` nie ma) + `}>` (ConsentProvider, baner, CookieButton, Analytics w dobrej kolejności); tryb okna ustawień (`settings`: `inline` / `modal` / `detailed`) wg designu, brief milczy → `detailed`, decyzja do „Ustaleń projektu”; ID narzędzi w panelu; lista ciasteczek ze skanu (cookie-scan → import) — zasila `` na stronie polityki **i** listy w oknie `detailed`; Cookie Settings → Detail labels w każdym języku | consent.md, analytics.md | A, `ipal-consent-check` | | 13 | Bezpieczeństwo | `buildSecurityHeaders` w `next.config.ts`; `twoFactor: { issuer, plugin: payloadTotp }`; CSP `report-only` → `enforce`; `IPAL_IP_HEADER` na produkcji | security.md, forms.md | A | | 14 | Operacje | `src/app/api/health/route.ts` (`healthRoute`); `src/instrumentation.ts` z `assertEnv(ipalEnvRules({ storage: true, ipHeader: true }))`; staging z `IPAL_NOINDEX=1`; testy smoke (§8a) | `healthRoute`, `assertEnv`, `ipalEnvRules` | A | | 15 | Strony systemowe | Site Settings → System Pages: homepage, 404, polityka prywatności, cookies; linki prawne w stopce przez rolę (`getSystemLinks(locale)`) | `getSystemLinks`, `getSystemPagePath`, `getNotFoundPage` | P | @@ -88,7 +113,7 @@ Nie warunkujesz providera ani widgetu w kodzie — wpinasz zawsze. | reCAPTCHA, hCaptcha, własna captcha | drugi mechanizm, brak statusu w panelu | Turnstile z pluginu | | ręczny `