feat(contracts): per-contract copy, header-free export, live language switch, contracts.txt#583
Conversation
…tch, contracts.txt - Export (copy & download) now emits paste-ready Markdown only: just "## Title" + template per contract, no "# Semantic Contracts" wrapper header and no "Generated from..." footer to trim. - Add a per-card copy button that copies just that one contract; it does not toggle the card's checkbox. - Fix language switch on /contracts: handleLanguageChange did not handle the route, so cards kept the old language until a full reload. Now the page re-renders on langchange. - Add website/public/contracts.txt — a contracts-only, LLM-readable plain text file generated from contracts.json, linked from the contracts page and referenced in llms.txt. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
WalkthroughDie PR erweitert die Semantic-Contracts-Funktionalität um einen automatisierten Plain-Text-Export, erweitert die Contracts-Page-UI um per-Card-Copy-Buttons, und implementiert die notwendigen Routing- und Internationalisierungsänderungen. Insgesamt werden 16 Code-Ranges auf vier Dateien (Skript, Komponente, Routing, i18n) plus eine neue Ausgabedatei verteilt. ChangesAutomatische Generierung und Plain-Text-Export von Semantic Contracts
Geschätzte Code-Review-Aufwand🎯 3 (Moderat) | ⏱️ ~20 Minuten Die Änderungen umfassen mehrere Dateien mit neuer Logik (Generierungsfunktion, Event-Handler, asynchrone Clipboard-Operationen), sind aber in sich konsistent und folgen etablierten Mustern. Die neue contracts.txt-Datei ist dokumentarisch und erfordert semantische Validierung gegen die existierenden Contracts, nicht jedoch Code-Review im klassischen Sinne. Möglicherweise verbundene PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/generate-llms-txt.js`:
- Line 380: The early-return for an invalid or empty contracts array is silent;
instead of simply returning in the condition that checks
Array.isArray(contracts) and contracts.length === 0, emit a warning consistent
with the earlier missing-file warning so callers can debug an empty
contracts.json; update the block that references the contracts variable (the if
(!Array.isArray(contracts) || contracts.length === 0) check) to log a warning
message (e.g., via console.warn or the module's logger) describing that
contracts.json exists but is empty or invalid before returning.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: d955e37f-f911-4fb3-a2aa-1972240639b4
📒 Files selected for processing (6)
scripts/generate-llms-txt.jswebsite/public/contracts.txtwebsite/src/components/contracts-page.jswebsite/src/main.jswebsite/src/translations/de.jsonwebsite/src/translations/en.json
| console.warn(' contracts.json not found — skipping contracts.txt') | ||
| return | ||
| } | ||
| if (!Array.isArray(contracts) || contracts.length === 0) return |
There was a problem hiding this comment.
Fehlende Warnung bei leerem Contracts-Array.
Die Funktion gibt bei einem leeren oder ungültigen Array stillschweigend zurück, während sie bei fehlendem contracts.json (Zeile 377) eine Warnung ausgibt. Das ist inkonsistent und erschwert das Debugging, wenn contracts.json existiert, aber leer ist.
🔧 Vorgeschlagener Fix
} catch {
console.warn(' contracts.json not found — skipping contracts.txt')
return
}
- if (!Array.isArray(contracts) || contracts.length === 0) return
+ if (!Array.isArray(contracts) || contracts.length === 0) {
+ console.warn(' contracts.json is empty or invalid — skipping contracts.txt')
+ return
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (!Array.isArray(contracts) || contracts.length === 0) return | |
| } catch { | |
| console.warn(' contracts.json not found — skipping contracts.txt') | |
| return | |
| } | |
| if (!Array.isArray(contracts) || contracts.length === 0) { | |
| console.warn(' contracts.json is empty or invalid — skipping contracts.txt') | |
| return | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@scripts/generate-llms-txt.js` at line 380, The early-return for an invalid or
empty contracts array is silent; instead of simply returning in the condition
that checks Array.isArray(contracts) and contracts.length === 0, emit a warning
consistent with the earlier missing-file warning so callers can debug an empty
contracts.json; update the block that references the contracts variable (the if
(!Array.isArray(contracts) || contracts.length === 0) check) to log a warning
message (e.g., via console.warn or the module's logger) describing that
contracts.json exists but is empty or invalid before returning.
Four UX fixes for the Semantic Contracts page, from user feedback.
1. Header-free export
Copy and download now produce paste-ready Markdown — just
## Title+ template per contract. Removed the# Semantic Contracts/ "Add this to your AGENTS.md…" intro header and the--- Generated from…footer, which had to be trimmed by hand before pasting into a CLAUDE.md / AGENTS.md.2. Per-contract copy button
Each card gets a small copy button that copies just that one contract. It does not toggle the card's selection checkbox (handled before the card-click toggle, with
stopPropagation).3. Live language switch (bug fix)
handleLanguageChangehad no/contractsbranch, so toggling DE/EN only updateddata-i18nchrome — the cards (titles, descriptions, templates) kept the old language until a full page reload. Now the page re-renders onlangchange.4.
contracts.txt(contracts-only, LLM-readable)New
website/public/contracts.txt, generated fromcontracts.jsonbygenerate-llms-txt.js(runs in the build). Linked from the contracts page and referenced in the mainllms.txt.Verification (dev server + Playwright)
## Specification\n\n…— no header; checkbox stayed unchecked.## Specification, no# Semantic Contractsheader, noGenerated fromfooter, 18##headings.Specification → Spezifikation, description and plain-text link switch live, no reload.contracts.txtgenerated (18 contracts, ~17 KB).website/andscripts/.Note (out of scope)
The committed
llms.txtanddocs/all-anchors.adoconmainare stale (152 vs 171 anchors; missing AIDA/Bloom's/DRY and the Privacy section). I deliberately left those out of this PR to keep it focused — they should be refreshed in a separate "regenerate generated docs" PR. The deploy build regenerates them anyway.🤖 Generated with Claude Code
Summary by CodeRabbit