@devalon.dev/credits 0.0.0-stage → 1.0.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 (63) hide show
  1. package/README.md +141 -2
  2. package/dist/chunk-QU6SEFG7.mjs +16 -0
  3. package/dist/chunk-SHIXBOQB.mjs +1 -0
  4. package/dist/chunk-YF7SVQTC.mjs +11 -0
  5. package/dist/core/agent-files.d.ts +46 -0
  6. package/dist/core/alternates.d.ts +4 -0
  7. package/dist/core/backlink.d.ts +24 -0
  8. package/dist/core/escape.d.ts +2 -0
  9. package/dist/core/headers.d.ts +34 -0
  10. package/dist/core/html.d.ts +27 -0
  11. package/dist/core/index.d.ts +13 -0
  12. package/dist/core/json-ld.d.ts +11 -0
  13. package/dist/core/url.d.ts +2 -0
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.js +1 -0
  16. package/dist/index.mjs +1 -0
  17. package/dist/next/agent-files.d.ts +2 -0
  18. package/dist/next/alternates.d.ts +4 -0
  19. package/dist/next/backlink.d.ts +5 -0
  20. package/dist/next/headers.d.ts +2 -0
  21. package/dist/next/index.d.ts +10 -0
  22. package/dist/next/index.js +16 -0
  23. package/dist/next/index.mjs +1 -0
  24. package/dist/next/json-ld.d.ts +5 -0
  25. package/dist/next/schema.d.ts +1 -0
  26. package/dist/next/types.d.ts +1 -0
  27. package/dist/react/agent-files.d.ts +2 -0
  28. package/dist/react/alternates.d.ts +5 -0
  29. package/dist/react/backlink.d.ts +5 -0
  30. package/dist/react/headers.d.ts +2 -0
  31. package/dist/react/html.d.ts +2 -0
  32. package/dist/react/index.d.ts +14 -0
  33. package/dist/react/index.js +26 -0
  34. package/dist/react/index.mjs +1 -0
  35. package/dist/react/json-ld.d.ts +5 -0
  36. package/dist/react/schema.d.ts +1 -0
  37. package/dist/react/types.d.ts +1 -0
  38. package/dist/schema.d.ts +1183 -0
  39. package/dist/types.d.ts +75 -0
  40. package/dist/vite/index.d.ts +2 -0
  41. package/dist/vite/index.js +32 -0
  42. package/dist/vite/index.mjs +7 -0
  43. package/dist/vite/plugin.d.ts +51 -0
  44. package/docs/nextjs/01-app-router.md +101 -0
  45. package/docs/nextjs/02-app-router-i18n.md +166 -0
  46. package/docs/nextjs/03-pages-router.md +127 -0
  47. package/docs/nextjs/04-metadata-and-csp.md +113 -0
  48. package/docs/nextjs/05-performance-checklist.md +67 -0
  49. package/docs/nextjs/06-backlink-component.md +203 -0
  50. package/docs/nextjs/07-validator.md +55 -0
  51. package/docs/nextjs/08-server-headers.md +122 -0
  52. package/docs/nextjs/09-llms-and-humans-txt.md +163 -0
  53. package/docs/react/01-ssr-setup.md +112 -0
  54. package/docs/react/02-csr-vite.md +116 -0
  55. package/docs/react/03-i18n.md +104 -0
  56. package/docs/react/04-metadata-and-csp.md +105 -0
  57. package/docs/react/05-backlink-component.md +89 -0
  58. package/docs/react/06-server-headers.md +150 -0
  59. package/docs/react/07-agent-files.md +136 -0
  60. package/docs/react/08-validator.md +56 -0
  61. package/docs/react/09-performance-checklist.md +76 -0
  62. package/package.json +71 -4
  63. package/scripts/check-devalon-credits.mjs +175 -0
@@ -0,0 +1,105 @@
1
+ # 04 — Metadata (canonical / hreflang) and CSP nonce
2
+
3
+ **When to read this:** you want canonical and `hreflang` links next to the attribution, or your site has a strict Content Security Policy that only allows inline scripts with a nonce.
4
+
5
+ ## The data helper
6
+
7
+ `build_devalon_alternates()` is shared with the Next.js entry. It validates and normalizes URLs (trailing slashes, query strings and hashes are removed):
8
+
9
+ ```ts
10
+ import { build_devalon_alternates } from "@devalon.dev/credits/react";
11
+
12
+ const { canonical, languages } = build_devalon_alternates({
13
+ canonical: "https://example.com/ro",
14
+ pages: {
15
+ ro: "https://example.com/ro",
16
+ ru: "https://example.com/ru",
17
+ en: "https://example.com/en",
18
+ },
19
+ });
20
+ // canonical: "https://example.com/ro"
21
+ // languages: { en: "https://example.com/en", ro: "https://example.com/ro", ru: "https://example.com/ru" }
22
+ ```
23
+
24
+ ## Declarative: `DevalonAlternates`
25
+
26
+ ```tsx
27
+ import { DevalonAlternates } from "@devalon.dev/credits/react";
28
+
29
+ <DevalonAlternates
30
+ canonical="https://example.com/ro"
31
+ pages={{
32
+ ro: "https://example.com/ro",
33
+ ru: "https://example.com/ru",
34
+ en: "https://example.com/en",
35
+ }}
36
+ />
37
+ ```
38
+
39
+ It renders `<link rel="canonical">` and one `<link rel="alternate" hreflang="…">` per provided language. With a head manager (or React 19 hoisting in a supported SSR setup), place it anywhere in the tree. If `curl` does not show the tags in the server HTML, use the explicit form below.
40
+
41
+ ## Explicit: `devalonAlternatesHtml` / `devalonHeadHtml`
42
+
43
+ ```ts
44
+ import { devalonHeadHtml, devalonAlternatesHtml } from "@devalon.dev/credits/react";
45
+
46
+ // Only the links, as a string:
47
+ const links = devalonAlternatesHtml({
48
+ canonical: "https://example.com/ro",
49
+ pages: { ro: "https://example.com/ro", en: "https://example.com/en" },
50
+ });
51
+
52
+ // JSON-LD + links together (recommended for a custom <head>):
53
+ const head = devalonHeadHtml({
54
+ site_url: "https://example.com",
55
+ site_name: "Example Inc.",
56
+ in_language: "ro",
57
+ page_url: "https://example.com/ro",
58
+ services: ["web_development"],
59
+ alternates: {
60
+ canonical: "https://example.com/ro",
61
+ pages: { ro: "https://example.com/ro", en: "https://example.com/en" },
62
+ },
63
+ });
64
+ ```
65
+
66
+ `devalonHeadHtml()` escapes all attributes and JSON-LD content. The JSON-LD serializer additionally converts `<`, `>`, `&`, U+2028 and U+2029 to Unicode escapes, so the script cannot break out of its element.
67
+
68
+ ## CSP nonce
69
+
70
+ If your CSP uses `script-src 'self' 'nonce-…'`, pass the **per-request** nonce:
71
+
72
+ ```tsx
73
+ // Declarative
74
+ <DevalonJsonLd nonce={nonce} site_url="https://example.com" site_name="Example Inc." />
75
+ ```
76
+
77
+ ```ts
78
+ // Explicit server head
79
+ devalonHeadHtml({
80
+ site_url: "https://example.com",
81
+ site_name: "Example Inc.",
82
+ nonce,
83
+ });
84
+ // -> <script type="application/ld+json" nonce="…">…</script>
85
+ ```
86
+
87
+ A hardcoded build-time nonce defeats the purpose of a CSP. Note that reading request headers to obtain the nonce makes that route dynamically rendered — use a nonce only when the CSP requires it.
88
+
89
+ ## Do not duplicate tags
90
+
91
+ If a framework head manager already emits canonical/hreflang, pick **one** source:
92
+
93
+ - Framework-managed → use `DevalonAlternates` (or your own `<link>` tags) and omit `alternates` from `devalonHeadHtml()`.
94
+ - Custom server template → `devalonHeadHtml({ ..., alternates })` and no declarative component.
95
+
96
+ Duplicate `<link rel="canonical">` is ambiguous to crawlers; duplicate JSON-LD graphs waste parse time.
97
+
98
+ ## Verify
99
+
100
+ ```bash
101
+ curl -s http://localhost:3000/ro | grep -o 'rel="canonical"[^>]*'
102
+ curl -s http://localhost:3000/ro | grep -o 'hreflang="[a-z]*"'
103
+ curl -sI http://localhost:3000/ro | grep -i content-security-policy
104
+ curl -s http://localhost:3000/ro | grep -o '<script[^>]*application/ld+json[^>]*>'
105
+ ```
@@ -0,0 +1,89 @@
1
+ # 05 — Backlink component (visible credit link)
2
+
3
+ **When to read this:** you want a visible credit on the client site that sends a clean `follow` link back to `devalon.dev`.
4
+
5
+ `DevalonBacklink` is the visible counterpart of the JSON-LD: crawlers read the graph, people read the link. It renders plain HTML — no JavaScript, no image, no hydration.
6
+
7
+ ## Declarative usage
8
+
9
+ ```tsx
10
+ import { DevalonBacklink } from "@devalon.dev/credits/react";
11
+
12
+ export function Footer() {
13
+ return (
14
+ <footer>
15
+ <DevalonBacklink locale="ro" />
16
+ </footer>
17
+ );
18
+ }
19
+ ```
20
+
21
+ Rendered HTML:
22
+
23
+ ```html
24
+ <span>Acest site a fost proiectat și construit de
25
+ <a href="https://devalon.dev" target="_blank" rel="noopener" referrerpolicy="origin">Devalon</a>
26
+ </span>
27
+ ```
28
+
29
+ It also works as a plain server-rendered element in any React setup. It does not need a `"use client"` boundary.
30
+
31
+ ## Explicit HTML string
32
+
33
+ When the body of your document is assembled as a string (custom SSR template, static site, CDN worker):
34
+
35
+ ```ts
36
+ import { devalonBacklinkHtml } from "@devalon.dev/credits/react";
37
+
38
+ const credit = devalonBacklinkHtml({ locale: "ro", className: "credit" });
39
+ // <span class="credit">Acest site ... <a href="https://devalon.dev" ...>Devalon</a></span>
40
+ ```
41
+
42
+ Or inject it automatically with `devalonInjectHtml(html, { ..., backlink: { locale: "ro" } })` — see [01 — SSR setup](01-ssr-setup.md) and [02 — CSR / Vite](02-csr-vite.md).
43
+
44
+ ## Props
45
+
46
+ | Prop | Required | Notes |
47
+ | --- | --- | --- |
48
+ | `site_url` | only with `utm` | Absolute http(s) URL of the client site. Only its hostname is used, for `utm_source`; `www.` is stripped. Invalid URLs throw a `TypeError`. |
49
+ | `locale` | no | One of `en`, `ro`, `ru`, `de`, `da`, `fr`, `es`. Selects the built-in sentence. Defaults to `en`. |
50
+ | `sentence` | no | Overrides the built-in sentence. Must not be empty. |
51
+ | `anchor` | no | Visible link text. Defaults to `Devalon`. Must not be empty. |
52
+ | `utm` | no | Appends `utm_source` / `utm_medium` / `utm_campaign`. Defaults to **false** — the link stays clean. |
53
+ | `className` | no | Your class for the wrapper `<span>`. The component ships no CSS. |
54
+
55
+ ## Optional UTM tracking
56
+
57
+ ```tsx
58
+ <DevalonBacklink site_url="https://example.com" utm />
59
+ // https://devalon.dev/?utm_source=example.com&utm_medium=credit&utm_campaign=devalon-credits
60
+ ```
61
+
62
+ UTM does not change the destination page and does not affect the value of the backlink. Leave it off unless you run a campaign; GA4 already records the client domain as a referral.
63
+
64
+ ## Quality rules
65
+
66
+ - It is a **credit / relationship link**: discovery, brand consistency, referral traffic. Not a commercial keyword ranking lever.
67
+ - Keep it a normal `follow` link: `rel="noopener"`, never `noreferrer`, `nofollow` or `sponsored` for a genuine credit.
68
+ - Keep it visibly readable. Hidden or 1px text can be treated as spam.
69
+ - Render it once, in the shared footer/layout, not in every page component.
70
+ - Do not create the link with `useEffect` / `document.createElement`; it must be in the initial HTML.
71
+
72
+ ## Common mistakes
73
+
74
+ | Don't | Do |
75
+ | --- | --- |
76
+ | `rel="noopener noreferrer"` | `rel="noopener"` only — `noreferrer` kills referral data. |
77
+ | `rel="nofollow"` for a genuine credit | Leave it a follow link. |
78
+ | `display:none`, white-on-white | Keep the text visibly readable. |
79
+ | Enable `utm` "just in case" | Leave it off; referral reporting is enough. |
80
+ | Pass a relative `site_url` | Pass an absolute `https://...` URL. |
81
+ | Put the credit on a `noindex` staging site | Run the validator first — [08 — Validator](08-validator.md). |
82
+
83
+ ## Verify
84
+
85
+ ```bash
86
+ curl -s http://localhost:3000/ | grep -o 'rel="noopener"'
87
+ curl -s http://localhost:3000/ro | grep -o 'Acest site a fost proiectat'
88
+ curl -s http://localhost:3000/ | grep -o 'https://devalon.dev' | wc -l # expect 1 in the body credit
89
+ ```
@@ -0,0 +1,150 @@
1
+ # 06 — Server utility: Devalon response headers
2
+
3
+ **When to read this:** you want `curl -I` (or your CDN, audit tooling, validator) to state who built the site, without adding React code.
4
+
5
+ This is a **server utility**, not a component. There is no JSX, no `"use client"`, no hydration. `devalonHeadersConfig()` returns plain `{ key, value }` pairs; `withDevalonHeaders()` writes them onto any object exposing a mutable `Headers` instance.
6
+
7
+ ## Express / Node
8
+
9
+ ```ts
10
+ import express from "express";
11
+ import { devalonHeadersMiddleware } from "@devalon.dev/credits/react";
12
+
13
+ const app = express();
14
+ const devalonConfig = {
15
+ site_url: "https://example.com",
16
+ services: ["web_development", "ai_agents_automation"] as const,
17
+ contributions: ["developing", "maintaining"] as const,
18
+ };
19
+
20
+ app.use(devalonHeadersMiddleware(devalonConfig));
21
+ ```
22
+
23
+ `devalonHeadersMiddleware()` is framework-agnostic: it only needs `req.url`, `res.getHeader()` and `res.setHeader()`. It detects the locale from the first path segment when you pass `localeFromPath: ["ro", "ru", "en"]`, and it **appends** to an existing `Link` header instead of overwriting it.
24
+
25
+ Or mutate a `Response` directly:
26
+
27
+ ```ts
28
+ import { withDevalonHeaders } from "@devalon.dev/credits/react";
29
+
30
+ const response = new Response(html, {
31
+ headers: { "Content-Type": "text/html; charset=utf-8" },
32
+ });
33
+
34
+ withDevalonHeaders(response, { ...devalonConfig, locale: "ro" });
35
+ ```
36
+
37
+ ## Automatic with the Vite plugin
38
+
39
+ `devalonVite()` handles all three environments from one config:
40
+
41
+ ```ts
42
+ // vite.config.ts
43
+ import { defineConfig } from "vite";
44
+ import { devalonVite } from "@devalon.dev/credits/vite";
45
+
46
+ export default defineConfig({
47
+ plugins: [
48
+ devalonVite({
49
+ site_url: "https://example.com",
50
+ site_name: "Example Inc.",
51
+ services: ["web_development"],
52
+ in_language: "en",
53
+
54
+ // dev + preview responses
55
+ headers: { localeFromPath: ["ro", "ru", "en"] },
56
+ // static production output
57
+ headersFile: "_headers", // or "vercel.json", "all", false
58
+ }),
59
+ ],
60
+ });
61
+ ```
62
+
63
+ | Setting | Effect |
64
+ | --- | --- |
65
+ | `headers` | `true` (default) installs middleware in `vite dev` and `vite preview`. `false` disables all header handling. An object sets a fixed `locale` and/or `localeFromPath`. |
66
+ | `headersFile` | `"_headers"` (default) writes a Netlify / Cloudflare Pages file; `"vercel.json"` writes Vercel config; `"all"` writes both; `false` skips it. |
67
+ | `in_language` | Used as the fixed `X-Devalon-Locale` when `localeFromPath` is not set. |
68
+
69
+ `localeFromPath` reads the first path segment (`/ro/page` → `ro`) per request. For a static SPA with no per-locale paths, use `headers: { locale: "ro" }` or rely on `in_language`.
70
+
71
+ The plugin **merges, never clobbers**: an existing `_headers` keeps its own rules (only the `# devalon:start/end` block is replaced), and an existing `vercel.json` keeps its rewrites/other header entries while the previous Devalon entry is removed. Repeated builds are identical.
72
+
73
+ ### Manual Vite config (without the plugin)
74
+
75
+ ```ts
76
+ import { defineConfig } from "vite";
77
+ import { devalonHeadersConfig } from "@devalon.dev/credits/react";
78
+
79
+ export default defineConfig({
80
+ server: {
81
+ headers: Object.fromEntries(
82
+ devalonHeadersConfig({ site_url: "https://example.com" }).map(
83
+ ({ key, value }) => [key, value],
84
+ ),
85
+ ),
86
+ },
87
+ });
88
+ ```
89
+
90
+ ## Headers emitted
91
+
92
+ ```
93
+ X-Devalon-Creator: Devalon
94
+ X-Devalon-Creator-Url: https://devalon.dev
95
+ X-Devalon-Creator-Id: https://devalon.dev/#organization
96
+ X-Devalon-Project: https://example.com
97
+ X-Devalon-Services: web_development, ai_agents_automation
98
+ X-Devalon-Contributions: developing, maintaining
99
+ X-Devalon-Relationships: creator, provider
100
+ X-Devalon-Locale: ro
101
+ X-Built-By: Devalon (https://devalon.dev)
102
+ Link: <https://devalon.dev>; rel="author"
103
+ ```
104
+
105
+ - `Services` are canonicalized: legacy aliases resolve to the current key, duplicates are removed.
106
+ - `Relationships` come from the same contribution mapping as the JSON-LD graph (`creator` / `maintainer` / `provider`).
107
+ - `X-Devalon-Locale` is emitted only when `locale` is provided; all 7 supported languages are accepted.
108
+ - Empty `services`, `contributions` or resolved relationships omit their respective header. `contributions` defaults to `["development", "engineering"]`.
109
+ - All values are ASCII, so `Headers` never rejects diacritics. The client name lives in the JSON-LD, not in headers.
110
+ - `withDevalonHeaders()` **appends** the `Link` header to any existing `Link` value instead of overwriting it.
111
+ - `X-Built-By` contains no framework/runtime versions — no stack fingerprinting.
112
+
113
+ ## What this is — and is not
114
+
115
+ - ✅ Operational metadata: instant provenance via `curl -I`, project inventory, audit and CDN debugging.
116
+ - ❌ **Not an SEO ranking factor.** Google ignores custom `X-` headers. They do not replace the JSON-LD or the visible credit.
117
+
118
+ ## CDN caveat
119
+
120
+ Vercel, Cloudflare, Coolify or a reverse proxy can rewrite or strip custom headers. After deployment, verify on the real URL:
121
+
122
+ ```bash
123
+ curl -sI https://client.com/ | grep -iE 'x-devalon|x-built-by|^link'
124
+ ```
125
+
126
+ If a header is missing, the platform is filtering it — not the code. The JSON-LD and the visible credit are not affected.
127
+
128
+ ## Common mistakes
129
+
130
+ | Don't | Do |
131
+ | --- | --- |
132
+ | Expect headers to affect rankings. | Use `DevalonJsonLd` / `devalonHeadHtml` for entity signals. |
133
+ | Pass a relative `site_url`. | Pass an absolute `https://...` URL. |
134
+ | Put a client name with diacritics in a header. | Keep it in JSON-LD; headers carry ASCII identifiers only. |
135
+ | Overwrite an existing `Link` header. | Use `withDevalonHeaders()` / `devalonHeadersMiddleware()`, which append. |
136
+ | Expect `vite dev` to read `_headers`. | The file is for production hosts; dev/preview use the middleware. |
137
+
138
+ ## Verify
139
+
140
+ ```bash
141
+ # SSR server / vite dev / vite preview
142
+ curl -sI http://localhost:3000/ | grep -i '^x-devalon'
143
+ curl -sI http://localhost:5173/ro | grep -i 'x-devalon-locale'
144
+
145
+ # static output before deploying
146
+ grep -i 'x-devalon' dist/_headers
147
+ grep -i 'X-Devalon' dist/vercel.json
148
+
149
+ yarn check:credits https://client.com --deployed
150
+ ```
@@ -0,0 +1,136 @@
1
+ # 07 — llms.txt and humans.txt (build-time, no manual editing)
2
+
3
+ **When to read this:** you want AI agents and curious humans to find an explicit credit, without anyone hand-editing a text file.
4
+
5
+ These are **plain-text identity files**, not ranking factors. They complement (never replace) the JSON-LD and the visible credit. All helpers are pure string transforms plus an optional `Response` wrapper — they never read or write files on disk themselves.
6
+
7
+ ## The idea
8
+
9
+ ```
10
+ client's original text (source) ──► merge ──► static llms.txt / humans.txt
11
+ ▲
12
+ Devalon credit block
13
+ ```
14
+
15
+ The credit is wrapped in markers and merged idempotently. Running the build 100 times produces the same file — no duplicate credits.
16
+
17
+ ## Recommended: Vite plugin
18
+
19
+ ```ts
20
+ // vite.config.ts
21
+ import { defineConfig } from "vite";
22
+ import { devalonVite } from "@devalon.dev/credits/vite";
23
+
24
+ export default defineConfig({
25
+ plugins: [
26
+ devalonVite({
27
+ site_url: "https://example.com",
28
+ site_name: "Example Inc.",
29
+ description: "Custom CRM and booking platform for clinics.",
30
+ services: ["web_development", "ai_agents_automation"],
31
+ agentFilesConfig: {
32
+ // existing client text, if there is any
33
+ source: "# Example\n\n> Official docs and product information.\n",
34
+ },
35
+ }),
36
+ ],
37
+ });
38
+ ```
39
+
40
+ The plugin writes `dist/llms.txt` and `dist/humans.txt`. Set `agentFiles: false` to skip. In the same `closeBundle` pass it also writes the platform header file (`dist/_headers` by default, or `vercel.json` / both via `headersFile`) — see [06 — Server headers](06-server-headers.md). All of these are generated together and all are idempotent. See [02 — CSR / Vite](02-csr-vite.md).
41
+
42
+ ## Build script without Vite
43
+
44
+ `devalonAgentFiles()` returns both files as plain strings, so any build step can write them:
45
+
46
+ ```js
47
+ // scripts/generate-agent-files.mjs
48
+ import { readFile, writeFile } from "node:fs/promises";
49
+ import { devalonAgentFiles } from "@devalon.dev/credits/react";
50
+
51
+ const files = devalonAgentFiles({
52
+ site_url: "https://example.com",
53
+ site_name: "Example Inc.",
54
+ description: "Custom CRM and booking platform for clinics.",
55
+ services: ["web_development"],
56
+ source: await readFile("content/llms.md", "utf8"), // optional
57
+ });
58
+
59
+ for (const [name, content] of Object.entries(files)) {
60
+ await writeFile(new URL(`../public/${name}`, import.meta.url), content, "utf8");
61
+ }
62
+ ```
63
+
64
+ If `source` is omitted or empty, a complete file is generated (H1, description, canonical URL, credit block). The same helper works whether or not a file existed before.
65
+
66
+ ## Server endpoints
67
+
68
+ For a server framework with route handlers, return a ready `Response`:
69
+
70
+ ```ts
71
+ import { devalonLlmsTxtResponse, devalonHumansTxtResponse } from "@devalon.dev/credits/react";
72
+
73
+ export function GET() {
74
+ return devalonLlmsTxtResponse({
75
+ site_url: "https://example.com",
76
+ site_name: "Example Inc.",
77
+ source: existingClientText,
78
+ });
79
+ }
80
+ ```
81
+
82
+ Both helpers set `Content-Type: text/plain; charset=utf-8`. The Vite plugin does not need these — they are for runtime endpoints.
83
+
84
+ ## API
85
+
86
+ | Function | Use |
87
+ | --- | --- |
88
+ | `devalonLlmsBlock(config)` | Markdown fragment only, for pasting into an existing `llms.txt`. |
89
+ | `mergeDevalonLlmsTxt(existing, config)` | Idempotent insert/update of the marked block. |
90
+ | `devalonLlmsTxt(config)` | Whole file string, when there is no source. |
91
+ | `devalonLlmsTxtResponse(config)` | Ready `Response` for a server endpoint. |
92
+ | `devalonHumansBlock(config)` | Text fragment for an existing `humans.txt`. |
93
+ | `mergeDevalonHumansTxt(existing, config)` | Idempotent insert/update, prefers `/* TEAM */`. |
94
+ | `devalonHumansTxt(config)` | Whole file string, when there is no source. |
95
+ | `devalonHumansTxtResponse(config)` | Ready `Response` for a server endpoint. |
96
+ | `devalonAgentFiles(config)` | Both generated files as `{ "llms.txt": string, "humans.txt": string }`. |
97
+
98
+ Config: `site_url` (absolute), `site_name`, optional `description`, `services`, `contributions`, `source`. Unknown service keys throw a `TypeError`.
99
+
100
+ Markers:
101
+
102
+ ```md
103
+ <!-- devalon:start -->
104
+ ## Credits
105
+
106
+ Built and maintained by [Devalon](https://devalon.dev), an AI & software development studio.
107
+ Services: Web Development, AI Agents & Automation.
108
+ <!-- devalon:end -->
109
+ ```
110
+
111
+ For `humans.txt` the markers are `/* devalon:start */` and `/* devalon:end */`, and the block is inserted into an existing `/* TEAM */` section when one exists.
112
+
113
+ ## Who owns the file
114
+
115
+ | Situation | What to do |
116
+ | --- | --- |
117
+ | Has the file and controls it | Pass its text as `source`; the credit is merged automatically. |
118
+ | CMS/hosting provider manages it | Do not touch it. Ask its owner to paste `devalonLlmsBlock(config)`, or rely on JSON-LD + footer + headers. |
119
+ | Has no file | Omit `source` — a full file is generated. |
120
+ | Does not want these files | Set `agentFiles: false` / skip the build step. Everything else still works. |
121
+
122
+ ## What this is — and is not
123
+
124
+ - ✅ Cheap, static, cacheable identity files generated at build, with unambiguous attribution for LLM crawlers and humans.
125
+ - ❌ `llms.txt` is a **convention**, not an official standard. Google has not said it uses it for ranking.
126
+ - ❌ It does not replace JSON-LD (`creator` / `provider`) or the visible credit link.
127
+
128
+ ## Verify
129
+
130
+ ```bash
131
+ yarn build
132
+ grep -i devalon.dev dist/llms.txt dist/humans.txt
133
+ yarn check:credits https://client.com --deployed
134
+ ```
135
+
136
+ The validator reports missing files or a missing mention as **warnings**, not errors: the files belong to the client.
@@ -0,0 +1,56 @@
1
+ # 08 — Credit link validator
2
+
3
+ **When to read this:** before deploying a credit, and after deployment, to confirm the client site is a place where the credit should live.
4
+
5
+ The validator checks the **client site**, not the package build. It is framework-agnostic: the same command works for Next.js, plain React, Vite or a static site.
6
+
7
+ ## Run it
8
+
9
+ ```bash
10
+ # Before deploying — the site should be live and indexable
11
+ yarn check:credits https://client.com
12
+
13
+ # After deployment — also inspects response headers and identity files
14
+ yarn check:credits https://client.com --deployed
15
+ ```
16
+
17
+ ## What it checks
18
+
19
+ | Area | What it looks for |
20
+ | --- | --- |
21
+ | Indexability | HTTP status, `robots` meta, `noindex`, redirect chains |
22
+ | JSON-LD | A Devalon attribution in the structured data |
23
+ | Visible credit | A link back to `devalon.dev` in the HTML |
24
+ | Headers | `X-Devalon-Creator`, `X-Devalon-Project`, `X-Built-By`, `Link: ... rel="author"` |
25
+ | Identity files | `/llms.txt` and `/humans.txt` mention Devalon |
26
+
27
+ Missing identity files or a missing mention are reported as **warnings**, not errors — those files belong to the client. Missing creator header is also a warning, since frameworks and CDNs can strip custom headers (see [06 — Server headers](06-server-headers.md)).
28
+
29
+ For a CSR app built with Vite, verify the generated HTML directly too — the plugin only affects `dist/index.html`, not `vite dev`:
30
+
31
+ ```bash
32
+ yarn build
33
+ grep -o 'application/ld+json' dist/index.html
34
+ grep -o 'https://devalon.dev' dist/index.html
35
+ ```
36
+
37
+ ## Quality gate
38
+
39
+ Only put the credit on sites that are live, indexed and have real traffic. A credit on a staging or `noindex` domain brings no value and can hurt both sides.
40
+
41
+ ## After the credit is live
42
+
43
+ - Keep one canonical `site_url` per client across all integrations (JSON-LD, headers, `llms.txt`, backlink UTM).
44
+ - Re-run the validator after each deployment.
45
+ - If you use UTM, create a GA4 **Custom channel group** named `Partner credits` with *Session source matches regex* containing your client domains (`client1\.com|client2\.com|...`). Without UTM, the default referral report is enough.
46
+
47
+ ## Common failures
48
+
49
+ | Symptom | Likely cause |
50
+ | --- | --- |
51
+ | JSON-LD missing | Credit rendered only after hydration; use `devalonHeadHtml()` or the Vite plugin. |
52
+ | Headers missing | CDN/proxy stripping custom `X-` headers, or middleware not applied. |
53
+ | `/llms.txt` missing | File not generated into the deployed output directory. |
54
+ | Duplicate canonical tags | Both a framework head manager and `devalonHeadHtml({ alternates })` are emitting them. |
55
+
56
+ The command never modifies files — it only fetches and reports.
@@ -0,0 +1,76 @@
1
+ # 09 — Performance checklist and final verification
2
+
3
+ **When to read this:** right before shipping a React / Vite integration, to make sure the credit costs nothing at runtime and is actually present in the served HTML.
4
+
5
+ ## Zero client cost
6
+
7
+ - ✅ The components render plain elements. No `"use client"`, no state, no effects, no event handlers.
8
+ - ✅ No hydration work is added — the markup is computed from static props at render/build time.
9
+ - ✅ No remote logo image: a text link adds zero requests.
10
+ - ✅ The JSON-LD is one inline `<script type="application/ld+json">`; the `serialize_json_ld()` step escapes `<`, `>`, `&`, U+2028 and U+2029 so it cannot break the page.
11
+ - ✅ The Vite plugin runs only during `apply: "build"` — nothing is bundled into the browser.
12
+
13
+ ## One credit per URL
14
+
15
+ Render the JSON-LD, canonical link and backlink **once** for each canonical URL:
16
+
17
+ - SSR: in the shared layout / HTML template, not in individual pages.
18
+ - CSR SPA: once in `index.html` via the Vite plugin, not in a component mounted in multiple routes.
19
+ - i18n: once per localized URL, with `page_url` and `alternates.canonical` set to that URL.
20
+
21
+ Duplicate JSON-LD graphs and duplicate canonical tags are worse than no credit at all.
22
+
23
+ ## HTML-first rule
24
+
25
+ The credit must exist in the response body before JavaScript runs. Check with `curl`, not with DevTools after hydration:
26
+
27
+ ```bash
28
+ # SSR server
29
+ curl -s http://localhost:3000/ | grep -o 'application/ld+json'
30
+ curl -s http://localhost:3000/ | grep -o 'rel="canonical"'
31
+ curl -s http://localhost:3000/ | grep -o 'rel="noopener"'
32
+ curl -sI http://localhost:5173/ | grep -i '^x-devalon' # Vite dev/preview middleware
33
+
34
+ # Vite build output
35
+ grep -o 'application/ld+json' dist/index.html
36
+ grep -o 'rel="canonical"' dist/index.html
37
+ grep -o 'https://devalon.dev' dist/index.html
38
+ grep -i 'x-devalon' dist/_headers
39
+ grep -i devalon.dev dist/llms.txt dist/humans.txt
40
+ ```
41
+
42
+ If a check fails:
43
+ 1. In SSR — use `devalonHeadHtml()` in your template instead of relying on head hoisting.
44
+ 2. In CSR — confirm the Vite plugin is in `plugins`, inspect `dist/index.html` (not `vite dev`).
45
+ 3. In i18n — confirm the locale-specific config is the one actually rendered.
46
+
47
+ ## Input hygiene
48
+
49
+ - `site_url` must be an absolute `http(s)` URL. Relative paths throw a `TypeError`.
50
+ - `site_name`, `sentence` and `anchor` must not be empty after trimming.
51
+ - Unknown service keys or locales throw a `TypeError` — fix them instead of casting.
52
+ - Use the same `site_url` in JSON-LD, headers, identity files and UTM. One source of truth.
53
+
54
+ ## Build & types
55
+
56
+ ```bash
57
+ yarn build # tsup bundles + tsc emits declarations for . /next /react /vite
58
+ ```
59
+
60
+ The published entry points are:
61
+
62
+ | Import | Contents |
63
+ | --- | --- |
64
+ | `@devalon.dev/credits` | Schema, catalogs, `build_devalon_json_ld`, `build_devalon_alternates` |
65
+ | `@devalon.dev/credits/next` | Next.js Server Components + Next-specific `Metadata` helper |
66
+ | `@devalon.dev/credits/react` | React components, server HTML helpers, headers, agent files |
67
+ | `@devalon.dev/credits/vite` | `devalonVite()` build-time plugin |
68
+
69
+ ## Final gate
70
+
71
+ ```bash
72
+ yarn check:credits https://client.com
73
+ yarn check:credits https://client.com --deployed
74
+ ```
75
+
76
+ Both must pass before the credit goes live — see [08 — Validator](08-validator.md).