Skip to content

feat(contracts): per-contract copy, header-free export, live language switch, contracts.txt#583

Merged
rdmueller merged 1 commit into
LLM-Coding:mainfrom
raifdmueller:feat/contracts-ux
Jun 8, 2026
Merged

feat(contracts): per-contract copy, header-free export, live language switch, contracts.txt#583
rdmueller merged 1 commit into
LLM-Coding:mainfrom
raifdmueller:feat/contracts-ux

Conversation

@raifdmueller

@raifdmueller raifdmueller commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

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)

handleLanguageChange had no /contracts branch, so toggling DE/EN only updated data-i18n chrome — the cards (titles, descriptions, templates) kept the old language until a full page reload. Now the page re-renders on langchange.

4. contracts.txt (contracts-only, LLM-readable)

New website/public/contracts.txt, generated from contracts.json by generate-llms-txt.js (runs in the build). Linked from the contracts page and referenced in the main llms.txt.

Verification (dev server + Playwright)

  • Per-card copy captured ## Specification\n\n… — no header; checkbox stayed unchecked.
  • Bulk copy (select-all): starts with ## Specification, no # Semantic Contracts header, no Generated from footer, 18 ## headings.
  • Language toggle: Specification → Spezifikation, description and plain-text link switch live, no reload.
  • contracts.txt generated (18 contracts, ~17 KB).
  • ESLint + Prettier pass for website/ and scripts/.

Note (out of scope)

The committed llms.txt and docs/all-anchors.adoc on main are 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

  • Neue Funktionen
    • Plain-Text-Version aller Semantic Contracts verfügbar – neue contracts.txt für maschinelle Lesbarkeit mit direktem Link auf der Vertragsseite.
    • Kopierschaltfläche für einzelne Verträge hinzugefügt – Nutzer können nun gezielt einzelne Verträge kopieren.
    • Sprachunterstützung auf der Vertragsseite verbessert – Sprachwechsel funktioniert nun korrekt.

…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>
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Die 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.

Changes

Automatische Generierung und Plain-Text-Export von Semantic Contracts

Layer / File(s) Zusammenfassung
Contracts.txt-Generierung und Ausgabedatei
scripts/generate-llms-txt.js, website/public/contracts.txt
generateContractsTxt() liest website/public/data/contracts.json, validiert die Array-Struktur und schreibt eine formatierte Plain-Text-Datei mit Kopfzeile, Kapiteln (Specification, Requirements Discovery, arc42, Prozesskonzepte, Socratic Code Theory, TDD Hamburg Style) und referenzierten Anchors. Die Funktion wird im Main-Abschnitt aufgerufen und ein Referenzlink in die llms.txt-Generierung eingefügt.
Contracts-Page UI mit per-Card-Copy und Plain-Text-Link
website/src/components/contracts-page.js
Neue Plain-Text-Link zu contracts.txt neben dem LinkedIn-Link; per-Card Copy-Button im Kartenkopf mit eigenem Klick-Handler via Event-Delegation; buildContractsMarkdown wird umgestellt auf einzelne ## {title}-Abschnitte ohne sprachabhängigen Header/Footer; neue copyOneContract Funktion schreibt Einzelverträge asynchron ins Clipboard mit temporärem Icon-Feedback.
Routing und Übersetzungen
website/src/main.js, website/src/translations/en.json, website/src/translations/de.json
handleLanguageChange() erweitert um /contracts-Route; zwei neue i18n-Keys (contracts.copyOne, contracts.plainText) in deutschen und englischen Translations.

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

  • LLM-Coding/Semantic-Anchors#367: Neue Contract-Einträge („concise-response", „simple-explanation") in website/public/data/contracts.json beeinflussen direkt den generierten Plain-Text-Output und die verfügbaren Download-Optionen.

  • LLM-Coding/Semantic-Anchors#525: Modifiziert das „socratic-code-theory-recovery"-Template in website/public/data/contracts.json, das die neue generateContractsTxt()-Funktion liest und in contracts.txt exportiert.

  • LLM-Coding/Semantic-Anchors#487: Verändert Templates in website/public/data/contracts.json direkt, woraus die neue Generierungsfunktion contracts.txt erzeugt.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.27% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Der Titel fasst alle vier Hauptänderungen zusammen: Per-Contract-Kopieren, kopfzeilenfreier Export, Live-Sprachwechsel und contracts.txt-Datei.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between b166cb7 and a7b3012.

📒 Files selected for processing (6)
  • scripts/generate-llms-txt.js
  • website/public/contracts.txt
  • website/src/components/contracts-page.js
  • website/src/main.js
  • website/src/translations/de.json
  • website/src/translations/en.json

console.warn(' contracts.json not found — skipping contracts.txt')
return
}
if (!Array.isArray(contracts) || contracts.length === 0) return

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

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.

Suggested change
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.

@rdmueller rdmueller merged commit a0ac096 into LLM-Coding:main Jun 8, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants