From 045e2e7202d242dd8c90af040261ea075fa0cfb3 Mon Sep 17 00:00:00 2001 From: Conrad Schulz Date: Sat, 30 May 2026 17:19:52 +0000 Subject: [PATCH] feat: add data/, history/, 3-target-group docs, pre-commit quality gate - New repo convention: /data// for all persistent service data (gitignored) - New repo convention: /history/prompts/ (gitignored) + /history/summary/PROJECT_CONTEXT.md for agent session logging and compressed project context - git-templates/hooks/pre-commit: quality gate checking tests + docs on every commit - git-templates/docs/: USER.md, ADMIN.md, MAINTAINER.md templates (3 target groups) - git-templates/history/summary/PROJECT_CONTEXT.md: agent context template - prompts/history.prompt.md: /history prompt for logging sessions + updating summary - copilot-bootstrap.sh: creates all new folders, .gitignore entries, installs hook - deploy.sh + deploy.fish: deploy hooks, doc templates, history template - docs/ADMIN.md: new admin handbook for this project - docs/USER.md + docs/MAINTAINER.md: updated with new conventions - git-templates/.github/copilot-instructions.md: extended DoD + new conventions - README.md: updated structure overview + prompt table --- README.md | 68 +++++++-- docs/ADMIN.md | 131 ++++++++++++++++++ docs/MAINTAINER.md | 124 +++++++++++++++++ docs/USER.md | 125 +++++++++++++++++ git-templates/.github/copilot-instructions.md | 32 ++++- git-templates/docs/ADMIN.md | 112 +++++++++++++++ git-templates/docs/MAINTAINER.md | 105 ++++++++++++++ git-templates/docs/USER.md | 57 ++++++++ .../history/summary/PROJECT_CONTEXT.md | 77 ++++++++++ git-templates/hooks/pre-commit | 96 +++++++++++++ prompts/history.prompt.md | 69 +++++++++ scripts/copilot-bootstrap.sh | 127 +++++++++++++++++ scripts/deploy.fish | 20 ++- scripts/deploy.sh | 28 +++- 14 files changed, 1148 insertions(+), 23 deletions(-) create mode 100644 docs/ADMIN.md create mode 100644 docs/MAINTAINER.md create mode 100644 docs/USER.md create mode 100644 git-templates/docs/ADMIN.md create mode 100644 git-templates/docs/MAINTAINER.md create mode 100644 git-templates/docs/USER.md create mode 100644 git-templates/history/summary/PROJECT_CONTEXT.md create mode 100755 git-templates/hooks/pre-commit create mode 100644 prompts/history.prompt.md create mode 100644 scripts/copilot-bootstrap.sh diff --git a/README.md b/README.md index 986455d..0677cff 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ Dieses Repo enthält alle Konfigurationsdateien die nötig sind um GitHub Copilo - **User-Level Settings** – Copilot-Flags und Senior-Dev-Grundverhalten (per Settings Sync auf alle Geräte) - **Prompt Files** – 9 wiederverwendbare Agent-Workflows (`/requirements`, `/new-feature`, `/architecture`, etc.) -- **Git-Templates** – automatisch in jedes neue Repo kopiert via `git init` -- **Bootstrap-Skript** – bestehende und geclonte Repos in Sekunden ausstatten +- **Git-Templates** – automatisch in jedes neue Repo kopiert via `git init` (per Git-Alias) +- **Bootstrap-Skript** – bestehende und geclonte Repos in Sekunden ausstatten (POSIX sh, läuft überall) --- @@ -33,7 +33,7 @@ Das Skript legt alles an den richtigen Orten ab. ```bash cd /path/to/existing-repo -fish ~/.local/bin/copilot-bootstrap.fish +copilot-bootstrap.sh # → legt .github/copilot-instructions.md + .vscode/ an, überschreibt nichts ``` @@ -59,17 +59,32 @@ rd13_copilot_setup/ │ ├── refactor.prompt.md /refactor – Refactoring ohne Behavior-Change │ ├── write-tests.prompt.md /write-tests – Test-Generierung │ ├── done-check.prompt.md /done-check – Definition of Done Checkliste -│ └── docker.prompt.md /docker – Docker/Compose-Aufgaben +│ ├── docker.prompt.md /docker – Docker/Compose-Aufgaben +│ └── history.prompt.md /history – Agent-History loggen + Kontext aktualisieren ├── git-templates/ ← Wird via git config --global init.templateDir gesetzt │ ├── .github/ -│ │ └── copilot-instructions.md ← Template mit TODO-Feldern -│ └── .vscode/ -│ ├── settings.json -│ └── extensions.json +│ │ └── copilot-instructions.md ← Template mit TODO-Feldern + Konventionen +│ ├── .vscode/ +│ │ ├── settings.json +│ │ └── extensions.json +│ ├── hooks/ +│ │ └── pre-commit ← Agent Quality Gate (Tests + Doku-Check) +│ ├── docs/ +│ │ ├── USER.md ← Template: Endnutzer-Dokumentation +│ │ ├── ADMIN.md ← Template: Administrator-Dokumentation +│ │ └── MAINTAINER.md ← Template: Entwickler-Dokumentation +│ └── history/ +│ └── summary/ +│ └── PROJECT_CONTEXT.md ← Template: Agent-Kontext-Summary +├── docs/ +│ ├── USER.md ← Benutzerhandbuch (Einrichtung + Nutzung) +│ ├── ADMIN.md ← Administrator-Handbuch (Deploy, Hooks, PATH) +│ └── MAINTAINER.md ← Architektur, Designentscheidungen, Erweiterung └── scripts/ - ├── deploy.sh ← Deployment-Skript (bash, für macOS) + ├── deploy.sh ← Deployment-Skript (bash, für macOS + Linux) ├── deploy.fish ← Deployment-Skript (fish, für Linux) - └── copilot-bootstrap.fish ← Einzelnes Repo ausstatten + ├── copilot-bootstrap.sh ← Einzelnes Repo ausstatten (POSIX sh, portabel) + └── copilot-bootstrap.fish ← Einzelnes Repo ausstatten (fish, legacy) ``` --- @@ -101,6 +116,24 @@ rd13_copilot_setup/ --- +## Was jedes Repo automatisch bekommt + +Nach `git init` (via Alias) oder `copilot-bootstrap.sh`: + +| Was | Wo | +|---|---| +| Copilot-Anweisungen + Konventionen | `.github/copilot-instructions.md` | +| VS Code-Einstellungen | `.vscode/` | +| **pre-commit Quality Gate** | `.git/hooks/pre-commit` | +| **Persistente Daten (gitignored)** | `data/` | +| **Agent-Konversationen (gitignored)** | `history/prompts/` | +| **Agent-Kontext-Summary (committed)** | `history/summary/PROJECT_CONTEXT.md` | +| **Endnutzer-Dokumentation** | `docs/USER.md` | +| **Administrator-Dokumentation** | `docs/ADMIN.md` | +| **Entwickler-Dokumentation** | `docs/MAINTAINER.md` | + +--- + ## Prompt Files – Wann was verwenden | Prompt | Aufruf | Wann verwenden | @@ -114,26 +147,31 @@ rd13_copilot_setup/ | `write-tests` | `/write-tests` | Test-Coverage-Lücken schließen | | `done-check` | `/done-check` | Abnahme-Check vor dem Merge (7-Punkte-Checkliste) | | `docker` | `/docker` | Docker/Compose analysieren, debuggen, erweitern | +| `history` | `/history` | Agent-Session loggen + Kontext-Summary aktualisieren | --- ## Neues Repo einrichten – Checkliste -Nach `git clone` oder `git init`: +Nach `git init` (mit eingerichtetem Alias) passiert alles **automatisch**. + +Nach `git clone` oder ohne Alias: ```bash # Option A: Bootstrap-Skript (empfohlen) -fish ~/.local/bin/copilot-bootstrap.fish +copilot-bootstrap.sh # Option B: Manuell mkdir -p .github .vscode -cp ~/dotfiles/copilot-setup/git-templates/.github/copilot-instructions.md .github/ -cp ~/dotfiles/copilot-setup/git-templates/.vscode/settings.json .vscode/ -cp ~/dotfiles/copilot-setup/git-templates/.vscode/extensions.json .vscode/ +cp ~/.git-templates/.github/copilot-instructions.md .github/ +cp ~/.git-templates/.vscode/settings.json .vscode/ +cp ~/.git-templates/.vscode/extensions.json .vscode/ ``` Danach: TODO-Felder in `.github/copilot-instructions.md` ausfüllen. +→ Detaillierte Anleitungen: [docs/USER.md](docs/USER.md) | [docs/MAINTAINER.md](docs/MAINTAINER.md) + --- ## .github/copilot-instructions.md ausfüllen diff --git a/docs/ADMIN.md b/docs/ADMIN.md new file mode 100644 index 0000000..bc4ca02 --- /dev/null +++ b/docs/ADMIN.md @@ -0,0 +1,131 @@ +# Administrator-Handbuch – rd13_copilot_setup + +> Zielgruppe: **Administratoren & DevOps** – Menschen, die das Setup deployen und auf Systemen verwalten. + +--- + +## Systemvoraussetzungen + +| Komponente | Anforderung | +|---|---| +| Git | ≥ 2.28 | +| Shell | POSIX sh (bash, dash) oder fish ≥ 3.x | +| VS Code / VS Code Server | beliebige aktuelle Version | +| OS | Linux oder macOS | + +--- + +## Deployment auf einem neuen System + +```bash +git clone ~/dotfiles/copilot-setup +cd ~/dotfiles/copilot-setup + +bash scripts/deploy.sh # bash (macOS + Linux) +# oder +fish scripts/deploy.fish # fish (Linux) +``` + +### Was das Deploy-Skript tut + +| Schritt | Was | Ziel | +|---|---|---| +| 1 | VS Code User-dir ermitteln | plattformspezifisch (Server / lokal / macOS) | +| 2 | `settings.json` deployen | `~/.vscode-server/data/User/` (oder Äquivalent) | +| 3 | Prompt Files deployen | `~/.vscode-server/data/User/prompts/` | +| 4 | Git-Templates deployen | `~/.git-templates/` inkl. Hooks, Docs, History-Template | +| 5 | Bootstrap-Skript installieren | `~/.local/bin/copilot-bootstrap.sh` | +| 6 | Git-Alias setzen | `~/.gitconfig` → `git init` ruft Bootstrap automatisch auf | + +--- + +## Git-Templates verwalten + +Die Templates unter `git-templates/` werden beim Deployen nach `~/.git-templates/` kopiert. +Sie werden bei **jedem** `git init` automatisch in neue Repos kopiert (via `init.templateDir`). + +**Struktur nach Deploy:** +``` +~/.git-templates/ +├── .github/copilot-instructions.md +├── .vscode/settings.json +├── .vscode/extensions.json +├── hooks/ +│ └── pre-commit ← Agent Quality Gate (ausführbar) +├── docs/ +│ ├── USER.md +│ ├── ADMIN.md +│ └── MAINTAINER.md +└── history/ + └── summary/ + └── PROJECT_CONTEXT.md +``` + +--- + +## pre-commit Hook verwalten + +Der Hook liegt in `git-templates/hooks/pre-commit` und wird automatisch deployed. + +**Hook aktivieren in bestehenden Repos (manuell):** +```bash +cp ~/.git-templates/hooks/pre-commit /path/to/repo/.git/hooks/pre-commit +chmod +x /path/to/repo/.git/hooks/pre-commit +``` + +**Hook deaktivieren (pro Commit):** +```bash +git commit --no-verify -m "..." +``` + +**Hook dauerhaft deaktivieren (pro Repo):** +```bash +chmod -x .git/hooks/pre-commit +``` + +--- + +## Bestehende Repos ausstatten + +```bash +cd /path/to/existing-repo +copilot-bootstrap.sh +# oder von überall: +sh ~/.local/bin/copilot-bootstrap.sh /path/to/repo +``` + +Das Bootstrap-Skript legt idempotent an: +- `.github/copilot-instructions.md` +- `.vscode/settings.json` + `.vscode/extensions.json` +- `data/` (gitignored) +- `history/prompts/` (gitignored) + `history/summary/PROJECT_CONTEXT.md` +- `docs/USER.md`, `docs/ADMIN.md`, `docs/MAINTAINER.md` +- `.git/hooks/pre-commit` +- `.gitignore`-Einträge für `data/**/*` und `history/prompts/*` + +--- + +## `~/.local/bin/` im PATH? + +Das Bootstrap-Skript wird in `~/.local/bin/` installiert. Sicherstellen dass dieser Pfad im `$PATH` ist: + +**bash/zsh** (`~/.bashrc` / `~/.zshrc`): +```bash +export PATH="$HOME/.local/bin:$PATH" +``` + +**fish** (`~/.config/fish/config.fish`): +```fish +fish_add_path ~/.local/bin +``` + +--- + +## Troubleshooting + +| Problem | Ursache | Lösung | +|---|---|---| +| `copilot-bootstrap.sh: command not found` | `~/.local/bin` nicht im PATH | Siehe "PATH" oben | +| `git init` ruft Bootstrap nicht auf | Git-Alias nicht gesetzt | `deploy.sh` erneut ausführen | +| Hook schlägt fehl obwohl alles ok | Falsch-positiver Match | `git commit --no-verify` | +| Hook nicht aktiv nach `git clone` | Hooks werden bei `clone` nicht kopiert | `copilot-bootstrap.sh` im geklonten Repo ausführen | diff --git a/docs/MAINTAINER.md b/docs/MAINTAINER.md new file mode 100644 index 0000000..6f4adc6 --- /dev/null +++ b/docs/MAINTAINER.md @@ -0,0 +1,124 @@ +# Maintainer-Handbuch – rd13_copilot_setup + +Dieses Dokument beschreibt Architektur, Designentscheidungen und wie das Projekt erweitert wird. + +--- + +## Architektur: 3-Schichten-Modell + +``` +┌─────────────────────────────────────────────────────────┐ +│ Layer 1: Immer aktiv (User settings.json) │ +│ • Senior-Dev-Grundregeln in codeGeneration.instructions │ +│ • Commit-Format, Review-Standard, Test-Standard │ +│ • Copilot Feature-Flags │ +├─────────────────────────────────────────────────────────┤ +│ Layer 2: Auf Abruf (Prompt Files ~/.vscode-server/…) │ +│ • /requirements /architecture /new-feature │ +│ • /code-review /debug /refactor │ +│ • /write-tests /done-check /docker │ +├─────────────────────────────────────────────────────────┤ +│ Layer 3: Repo-spezifisch (.github/copilot-instructions) │ +│ • Stack, Konventionen, ADR-Entscheidungen │ +│ • Definition of Done für dieses Projekt │ +│ • NFRs (Performance, Availability, Security) │ +└─────────────────────────────────────────────────────────┘ +``` + +--- + +## Dateistruktur + +``` +rd13_copilot_setup/ +├── docs/ +│ ├── USER.md ← Endnutzer-Dokumentation +│ ├── ADMIN.md ← Administrator-Dokumentation (Deploy, Hooks, PATH) +│ └── MAINTAINER.md ← Dieses Dokument +├── git-templates/ ← Template-Quellen für neue Repos +│ ├── .github/ +│ │ └── copilot-instructions.md ← Wird pro Repo individualisiert (TODO-Felder) +│ ├── .vscode/ +│ │ ├── settings.json ← Repo-spezifische VS Code Einstellungen +│ │ └── extensions.json ← Empfohlene Extensions für neue Repos +│ ├── hooks/ +│ │ └── pre-commit ← Agent Quality Gate (Tests + Doku-Check) +│ ├── docs/ +│ │ ├── USER.md ← Template Endnutzer-Doku +│ │ ├── ADMIN.md ← Template Admin-Doku +│ │ └── MAINTAINER.md ← Template Maintainer-Doku +│ └── history/ +│ └── summary/ +│ └── PROJECT_CONTEXT.md ← Template Agent-Kontext-Summary +├── prompts/ ← Wiederverwendbare Copilot-Workflows +│ └── *.prompt.md +├── scripts/ +│ ├── deploy.sh ← Bash-Deploy (macOS + Linux) +│ ├── deploy.fish ← Fish-Deploy (Linux) +│ ├── copilot-bootstrap.sh ← POSIX-sh Bootstrap für einzelne Repos (Haupt-Script) +│ └── copilot-bootstrap.fish ← Fish-Variante (legacy, optional) +└── user-settings/ + └── settings.json ← VS Code User-Level Settings (Layer 1) +``` + +--- + +## Wie `git init` automatisiert wird + +Git hat keinen `post-init` Hook – `.github/` und `.vscode/` befinden sich im Working Tree, nicht in `.git/`, weshalb `init.templateDir` allein nicht ausreicht. + +**Lösung: Git-Alias mit Rekursionsschutz** + +In `~/.gitconfig` (wird von deploy.sh/.fish gesetzt): +```ini +[alias] + init = !f() { dir=.; for a in "$@"; do case "$a" in -*) ;; *) dir="$a" ;; esac; done; "$(git --exec-path)/git-init" "$@" && "$HOME/.local/bin/copilot-bootstrap.sh" "$dir"; }; f +``` + +- `!` → externer Shell-Befehl (via `/bin/sh`), kein Git-Subcommand +- `$(git --exec-path)/git-init` → ruft das echte `git-init`-Binary direkt auf, umgeht den Alias → **kein Rekursions-Loop** +- Letzte Nicht-Flag-Argument wird als Zielverzeichnis erkannt (`dir=.` als Default) +- Nach erfolgreichem `git init` wird `copilot-bootstrap.sh` ausgeführt + +--- + +## Neuen Prompt hinzufügen + +1. Datei `prompts/mein-workflow.prompt.md` anlegen +2. Format: + ```markdown + --- + mode: agent + description: Kurzbeschreibung für den Chat-Slash-Command + --- + # Mein Workflow + … + ``` +3. `deploy.sh` erneut ausführen → deployed die neue Datei in `~/.vscode-server/…/prompts/` +4. In `README.md` und `docs/USER.md` in der Prompt-Tabelle eintragen +5. Committen + +## Template-Dateien ändern + +Dateien unter `git-templates/` bearbeiten → `deploy.sh` ausführen → neue Repos bekommen die neue Version. Bestehende Repos werden **nicht** automatisch aktualisiert (Bootstrap überschreibt nicht). + +**Wichtig beim Ändern von `git-templates/hooks/pre-commit`:** Die Datei muss nach dem Deployen ausführbar sein (`chmod +x`). `deploy.sh` erledigt das automatisch. + +## Deploy-Skripte ändern + +`deploy.sh` (bash) ist die Referenzimplementierung. `deploy.fish` sollte immer dieselben Schritte in Fish-Syntax abbilden. Nach Änderungen beide synchron halten. + +--- + +## Designentscheidungen + +| Entscheidung | Begründung | +|---|---| +| POSIX sh für Bootstrap-Script | Läuft auf jedem System ohne extra Dependencies (kein fish nötig) | +| Git-Alias statt Fish-Wrapper | Portabel: funktioniert in bash, sh, CI, GUI-Clients – nicht nur in fish | +| `git --exec-path` statt `command git` | `command` umgeht Aliases in fish/zsh, aber nicht in POSIX sh; `--exec-path` ist universell | +| Templates nicht auto-updaten | Idempotenz: Bootstrap überschreibt nie – Nutzer können Templates nach Init anpassen | +| 3 Zielgruppen-Docs (USER/ADMIN/MAINTAINER) | Klare Trennung: Nutzer ≠ Ops ≠ Dev; jede Gruppe findet ihren Kontext direkt | +| `data/` gitignored, Ordner-Struktur tracked | Persistente Daten gehören nie ins Git; Struktur als Konvention dokumentiert | +| `history/prompts/` gitignored | Agent-Logs können groß und vertraulich sein; nur der komprimierte Kontext (summary) wird committed | +| pre-commit Hook als Quality Gate | Automatisches Netz verhindert dass Tests/Doku vergessen werden; `--no-verify` bleibt als bewusstes Escape-Valve | diff --git a/docs/USER.md b/docs/USER.md new file mode 100644 index 0000000..8a68af8 --- /dev/null +++ b/docs/USER.md @@ -0,0 +1,125 @@ +# Benutzerhandbuch – rd13_copilot_setup + +Dieses Dokument erklärt wie du das Copilot-Setup auf einem neuen System einrichtest und täglich nutzt. + +--- + +## Ersteinrichtung auf einem neuen System + +### Schritt 1: Repo klonen + +```bash +git clone ~/dotfiles/copilot-setup +cd ~/dotfiles/copilot-setup +``` + +### Schritt 2: Deploy-Skript ausführen + +```bash +bash scripts/deploy.sh # macOS oder Linux (bash) +fish scripts/deploy.fish # Linux mit fish-Shell +``` + +Das Skript erledigt **einmalig** alles automatisch: + +| Was | Wo | +|---|---| +| VS Code User-Settings | `~/.vscode-server/data/User/settings.json` (Remote) / `~/.config/Code/User/` (lokal) | +| Prompt Files | `~/.vscode-server/data/User/prompts/` | +| Git-Templates | `~/.git-templates/` | +| Bootstrap-Skript | `~/.local/bin/copilot-bootstrap.sh` | +| Git-Alias `init` | `~/.gitconfig` | + +### Schritt 3: VS Code Settings Sync aktivieren (optional) + +`Ctrl+Shift+P` → **Settings Sync: Turn On** → Mit GitHub-Account einloggen → Alle Elemente auswählen + +--- + +## Tägliche Nutzung + +### Neues Repo anlegen + +```bash +git init mein-projekt +cd mein-projekt +``` + +Der `git init`-Alias legt automatisch `.github/copilot-instructions.md` und `.vscode/` an. Danach: + +1. Die `TODO`-Felder in `.github/copilot-instructions.md` ausfüllen +2. Committen: + ```bash + git add .github .vscode + git commit -m "chore: add copilot workspace config" + ``` + +### Bestehendes oder geklontes Repo ausstatten + +```bash +cd /pfad/zum/repo +copilot-bootstrap.sh +# oder: sh ~/.local/bin/copilot-bootstrap.sh +``` + +### Prompt Files im Chat nutzen + +In GitHub Copilot Chat einfach `/` tippen: + +| Prompt | Wofür | +|---|---| +| `/requirements` | Requirements Engineering Workshop | +| `/architecture` | Architektur-Review + ADR erstellen | +| `/new-feature` | Vollständiger Feature-Workflow | +| `/code-review` | Security + Qualitäts-Review | +| `/debug` | Root-Cause-Analyse + Fix | +| `/refactor` | Refactoring ohne Behavior-Change | +| `/write-tests` | Test-Generierung | +| `/done-check` | Definition of Done Checkliste | +| `/docker` | Docker/Compose-Aufgaben | +| `/history` | Agent-History loggen + Kontext-Summary aktualisieren | + +--- + +## Was jedes neue Repo bekommt + +Nach `git init` oder `copilot-bootstrap.sh` erhält jedes Repo automatisch: + +| Was | Wo | Zweck | +|---|---|---| +| Copilot-Anweisungen | `.github/copilot-instructions.md` | Agent-Verhalten für dieses Repo | +| VS Code-Einstellungen | `.vscode/settings.json` | Repo-spezifische Editor-Konfiguration | +| Empfohlene Extensions | `.vscode/extensions.json` | Extension-Vorschläge für das Team | +| Persistente Daten | `data/` | Service-Daten getrennt nach Service-Namen | +| Agent-Logs | `history/prompts/` | Vollständige Konversationen (gitignored) | +| Agent-Kontext | `history/summary/PROJECT_CONTEXT.md` | Komprimierter Projektzustand für Agenten | +| Nutzer-Doku | `docs/USER.md` | Dokumentation für Endnutzer | +| Admin-Doku | `docs/ADMIN.md` | Dokumentation für Administratoren | +| Entwickler-Doku | `docs/MAINTAINER.md` | Dokumentation für Entwickler | +| Quality-Gate-Hook | `.git/hooks/pre-commit` | Prüft Tests + Doku bei jedem Commit | + +--- + +## Häufige Fragen + +**`copilot-bootstrap.sh: command not found`** +`~/.local/bin` ist nicht im PATH. Entweder direkt aufrufen: `sh ~/.local/bin/copilot-bootstrap.sh` +Oder in `~/.bashrc` / `~/.config/fish/config.fish` hinzufügen: +```bash +export PATH="$HOME/.local/bin:$PATH" # bash/zsh +``` +```fish +fish_add_path ~/.local/bin # fish +``` + +**`git init` legt keine Copilot-Dateien an** +Das deploy-Skript wurde noch nicht auf diesem System ausgeführt. Schritt 1+2 wiederholen. + +**Der pre-commit Hook blockiert meinen Commit** +Der Hook hat Tests oder Dokumentation vermisst. Optionen: +- Tests schreiben: Copilot Chat → `/write-tests` +- Dokumentation aktualisieren: `docs/USER.md`, `docs/ADMIN.md` oder `docs/MAINTAINER.md` +- Bewusst überspringen: `git commit --no-verify` (bitte sparsam verwenden) + +**Ich will die Templates aktualisieren** +Im `rd13_copilot_setup`-Repo die Dateien in `git-templates/` ändern, committen, dann `deploy.sh` erneut ausführen. diff --git a/git-templates/.github/copilot-instructions.md b/git-templates/.github/copilot-instructions.md index a3baeb4..5b97c6d 100644 --- a/git-templates/.github/copilot-instructions.md +++ b/git-templates/.github/copilot-instructions.md @@ -16,6 +16,31 @@ - Key constraints: - ADR location: `docs/adr/` +## Project Structure Conventions + +### Persistent Data (`/data/`) +- **Alle persistenten Service-Daten** gehören in `/data//` (Repo-Root) +- **Nie** Daten-Dateien committen – `/data/` ist vollständig gitignored +- Einen Unterordner pro Service (z.B. `data/postgres/`, `data/redis/`, `data/uploads/`) +- Erforderliche Unterordner in `docs/ADMIN.md` dokumentieren + +### Agent History (`/history/`) +- **Vollständige Konversationen** → `history/prompts/YYYY-MM-DD_beschreibung.md` (gitignored) +- **Komprimierter Kontext** → `history/summary/PROJECT_CONTEXT.md` (**committed, immer aktuell halten!**) +- **Beim Start einer neuen Session:** `history/summary/PROJECT_CONTEXT.md` zuerst lesen +- **Am Ende jeder Session:** `PROJECT_CONTEXT.md` aktualisieren und committen +- Copilot Chat: `/history` → History loggen + Summary aktualisieren + +### Documentation (3 Zielgruppen – alle 3 müssen existieren) +| Datei | Zielgruppe | Inhalt | +|---|---|---| +| `docs/USER.md` | Endnutzer | Features, How-To, FAQ – keine technischen Details | +| `docs/ADMIN.md` | Administratoren | Deployment, Konfiguration, Monitoring, Backup | +| `docs/MAINTAINER.md` | Entwickler | Architektur, ADRs, Konventionen, Erweiterung | + +**Regel:** Jede bedeutende Änderung muss mindestens eine dieser Dateien aktualisieren. +Der pre-commit Hook prüft dies automatisch. + ## Conventions - Branch naming: `feat/-description`, `fix/-description` @@ -46,9 +71,13 @@ A task is only done when ALL of the following are true: - [ ] No linter / type errors - [ ] No secrets or credentials in code - [ ] OWASP Top 10 reviewed -- [ ] Relevant documentation updated (README, API docs, ADR if applicable) +- [ ] Relevant documentation updated: `docs/USER.md` and/or `docs/ADMIN.md` and/or `docs/MAINTAINER.md` +- [ ] Alle 3 Zielgruppen-Dokumente vorhanden (`docs/USER.md`, `docs/ADMIN.md`, `docs/MAINTAINER.md`) +- [ ] Persistente Daten liegen ausschließlich in `/data//` (nie woanders) +- [ ] `history/summary/PROJECT_CONTEXT.md` aktualisiert - [ ] Commit message follows Conventional Commits - [ ] No dead code, no TODOs left behind (or tracked as issues) +- [ ] pre-commit Quality Gate bestanden (oder Bypass bewusst begründet) ## Testing Strategy @@ -68,6 +97,7 @@ A task is only done when ALL of the following are true: - Public APIs: always documented - Architecture decisions: write ADR in `docs/adr/` (template: `docs/adr/000-template.md`) - CHANGELOG.md: update with every release +- **3-Zielgruppen-Regel:** USER.md (Endnutzer) + ADMIN.md (Ops) + MAINTAINER.md (Dev) – immer alle 3 pflegen ## Non-Functional Requirements diff --git a/git-templates/docs/ADMIN.md b/git-templates/docs/ADMIN.md new file mode 100644 index 0000000..23f6b0d --- /dev/null +++ b/git-templates/docs/ADMIN.md @@ -0,0 +1,112 @@ +# Administrator-Handbuch – [PROJEKT_NAME] + +> Zielgruppe: **Administratoren** – Menschen, die das System betreiben, deployen und konfigurieren. +> Voraussetzung: Grundkenntnisse in Linux, Docker und dem eingesetzten Stack. + +--- + +## Systemvoraussetzungen + + + +| Komponente | Mindestanforderung | Empfohlen | +|---|---|---| +| OS | … | … | +| RAM | … | … | +| Disk | … | … | +| Dependencies | … | … | + +--- + +## Deployment + +### Erstes Aufsetzen + + + +```bash +# Beispiel +git clone /opt/service +cd /opt/service +cp .env.example .env +# .env ausfüllen! +docker compose up -d +``` + +### Updates einspielen + + + +```bash +git pull +docker compose pull +docker compose up -d --force-recreate +``` + +--- + +## Konfiguration + +### Umgebungsvariablen (`.env`) + + + +| Variable | Pflicht | Default | Beschreibung | +|---|---|---|---| +| `EXAMPLE_VAR` | ✓ | – | Beschreibung | + +### Persistente Daten (`/data/`) + +Alle persistenten Daten liegen unter `/data//` im Repo-Root: + + + +| Pfad | Inhalt | Backup-Priorität | +|---|---|---| +| `data//` | … | hoch/mittel/niedrig | + +**Backup-Hinweise:** +- `/data/` komplett sichern vor jedem Update +- Empfehlung: tägliches Backup via Cron / Restic / rsync + +--- + +## Monitoring & Logs + + + +```bash +# Logs ansehen +docker compose logs -f + +# Status prüfen +docker compose ps +``` + +--- + +## Sicherheit + + + +- Offene Ports: … +- TLS: … +- Zugriffskontrolle: … + +--- + +## Troubleshooting + +| Symptom | Ursache | Lösung | +|---|---|---| +| … | … | … | + +--- + +## Disaster Recovery + + + +1. Dienst stoppen: `docker compose down` +2. Backup einspielen: … +3. Dienst neu starten: `docker compose up -d` diff --git a/git-templates/docs/MAINTAINER.md b/git-templates/docs/MAINTAINER.md new file mode 100644 index 0000000..cc49fd3 --- /dev/null +++ b/git-templates/docs/MAINTAINER.md @@ -0,0 +1,105 @@ +# Maintainer-Handbuch – [PROJEKT_NAME] + +> Zielgruppe: **Entwickler & Maintainer** – Menschen, die den Code verstehen, erweitern oder reviewen. +> Voraussetzung: Entwicklungserfahrung mit dem eingesetzten Stack. + +--- + +## Architektur + + + +``` +┌──────────────────────────────────────────────────────────┐ +│ TODO: Architektur-Diagramm (ASCII oder Mermaid) │ +└──────────────────────────────────────────────────────────┘ +``` + +**Wichtige Komponenten:** + +| Komponente | Verantwortlichkeit | Ort | +|---|---|---| +| … | … | `src/…` | + +--- + +## Projektstruktur + +``` +[PROJEKT_NAME]/ +├── data/ ← Persistente Daten (gitignored) +│ └── / ← Ein Unterordner pro Service +├── docs/ +│ ├── USER.md ← Endnutzer-Dokumentation +│ ├── ADMIN.md ← Administrator-Dokumentation +│ └── MAINTAINER.md ← Dieses Dokument +├── history/ +│ ├── prompts/ ← Vollständige Agent-Konversationen (gitignored) +│ └── summary/ +│ └── PROJECT_CONTEXT.md ← Aktueller Projektzustand für Agent-Kontext +└── … ← Source Code +``` + +--- + +## Entwicklungsumgebung aufsetzen + + + +```bash +git clone +cd +# Dependencies installieren +# Dev-Server starten +``` + +--- + +## Architekturentscheidungen (ADRs) + +ADR-Dateien liegen unter `docs/adr/`. Format: `NNN-titel.md`. + +| Nr. | Titel | Status | Datum | +|---|---|---|---| +| 000 | Template | accepted | … | + +--- + +## Coding-Konventionen + + + +- **Branches:** `feat/-beschreibung`, `fix/-beschreibung` +- **Commits:** Conventional Commits (`feat|fix|chore|docs|refactor|test|ci`) +- **Tests:** `tests/` spiegelt Source-Struktur, ≥ 80% Coverage +- **Linting:** … + +--- + +## Agent-Kontext & History + +Der Agent liest beim Start immer `history/summary/PROJECT_CONTEXT.md`. +Nach Abschluss einer Aufgabe wird dort der Projektzustand aktualisiert. + +- Vollständige Konversationen: `history/prompts/` (gitignored, lokal) +- Komprimierter Kontext: `history/summary/PROJECT_CONTEXT.md` (committed) + +--- + +## Neues Feature hinzufügen + +1. `history/summary/PROJECT_CONTEXT.md` lesen – aktuellen Stand verstehen +2. Issue / Ticket anlegen +3. Branch: `git checkout -b feat/-beschreibung` +4. Implementieren + Tests schreiben +5. Dokumentation in `docs/USER.md` oder `docs/ADMIN.md` aktualisieren +6. `git commit` – Quality Gate läuft automatisch (pre-commit hook) +7. PR erstellen + Review + +--- + +## Designentscheidungen + +| Entscheidung | Begründung | +|---|---| +| … | … | diff --git a/git-templates/docs/USER.md b/git-templates/docs/USER.md new file mode 100644 index 0000000..de6549c --- /dev/null +++ b/git-templates/docs/USER.md @@ -0,0 +1,57 @@ +# Benutzerhandbuch – [PROJEKT_NAME] + +> Zielgruppe: **Endnutzer** – Menschen, die das Produkt täglich verwenden. +> Keine Kenntnisse über interne Architektur oder Deployment notwendig. + +--- + +## Was macht dieses Projekt? + + + +--- + +## Voraussetzungen + + + +- [ ] Anforderung 1 +- [ ] Anforderung 2 + +--- + +## Erste Schritte + +### Schritt 1: Installation / Zugang + + + +### Schritt 2: Erste Nutzung + + + +--- + +## Hauptfunktionen + + + +### Feature 1 + +### Feature 2 + +--- + +## Häufige Probleme & Lösungen + + + +| Problem | Lösung | +|---------|--------| +| … | … | + +--- + +## Support + + diff --git a/git-templates/history/summary/PROJECT_CONTEXT.md b/git-templates/history/summary/PROJECT_CONTEXT.md new file mode 100644 index 0000000..332c69b --- /dev/null +++ b/git-templates/history/summary/PROJECT_CONTEXT.md @@ -0,0 +1,77 @@ +# PROJECT_CONTEXT – [PROJEKT_NAME] + +> Diese Datei ist der **persistente Gedächtnis-Speicher** für alle Agenten. +> Beim Start jeder neuen Agent-Session: **diese Datei zuerst lesen**. +> Nach Abschluss einer Aufgabe: **diesen Stand aktualisieren**. + +--- + +## Aktueller Projektstatus + +**Letzte Aktualisierung:** +**Phase:** + +--- + +## Was ist dieses Projekt? + + + +**Stack:** +**Deployment:** + +--- + +## Erledigte Aufgaben (neueste zuerst) + + + +| Datum | Aufgabe | Ergebnis | Entscheidungen | +|---|---|---|---| +| … | … | … | … | + +--- + +## Offene Aufgaben & bekannte Probleme + + + +- [ ] TODO 1 +- [ ] TODO 2 + +--- + +## Kritische Architekturentscheidungen + + + +| Entscheidung | Begründung | Wo dokumentiert | +|---|---|---| +| … | … | `docs/adr/NNN-…md` | + +--- + +## Wichtige Pfade & Konventionen + +- **Persistente Daten:** `/data//` (gitignored, nie committen!) +- **Agent-Logs (voll):** `/history/prompts/` (gitignored, lokal) +- **Dieser Kontext:** `/history/summary/PROJECT_CONTEXT.md` (committed) +- **Tests:** `tests/` (Struktur spiegelt Source) +- **Docs:** `docs/USER.md` | `docs/ADMIN.md` | `docs/MAINTAINER.md` + +--- + +## Für den nächsten Agenten: Startpunkt + + + +1. … +2. … + +--- + +## Bekannte Fallstricke / "Don't do this" + + + +- … diff --git a/git-templates/hooks/pre-commit b/git-templates/hooks/pre-commit new file mode 100755 index 0000000..39809ce --- /dev/null +++ b/git-templates/hooks/pre-commit @@ -0,0 +1,96 @@ +#!/usr/bin/env sh +# pre-commit – Agent Quality Gate +# +# Prüft bei jeder Code-Änderung ob: +# 1. Tests erstellt oder aktualisiert wurden +# 2. Mindestens eine Zielgruppen-Dokumentation aktualisiert wurde +# 3. Alle 3 Dokumentations-Zielgruppen vorhanden sind (USER/ADMIN/MAINTAINER) +# +# Bypass (bewusst): git commit --no-verify + +STAGED=$(git diff --cached --name-only --diff-filter=ACMR 2>/dev/null) +ERRORS=0 + +# Quellcode-Dateien (keine Tests, keine Konfiguration, keine Docs, keine Daten) +CODE_CHANGED=$(printf '%s\n' "$STAGED" \ + | grep -E '\.(py|js|ts|mjs|cjs|go|java|rs|rb|php|c|cpp|h|hpp|cs|kt|swift|sh|bash)$' \ + | grep -v -E '(test|spec|__tests__|_test)\.(py|js|ts|mjs|go|java|rs|rb|php|c|cpp|cs|kt|swift)$' \ + | grep -v -E '^(docs/|\.github/|\.vscode/|data/|history/)' \ + | grep -v -E '_test\.go$') + +# Keine Code-Änderungen → Hook überspringen +if [ -z "$CODE_CHANGED" ]; then + exit 0 +fi + +# ── Check 1: Tests ──────────────────────────────────────────────────────────── +TESTS_CHANGED=$(printf '%s\n' "$STAGED" \ + | grep -E '(test|spec|__tests__|_test)\.(py|js|ts|mjs|go|java|rs|rb|php|c|cpp|cs|kt|swift)$|_test\.go$|test_.*\.py$') + +if [ -z "$TESTS_CHANGED" ]; then + echo "" + echo "✗ AGENT QUALITY GATE [1/3]: Keine Test-Dateien geändert" + echo " Code-Änderungen ohne Test-Updates:" + printf '%s\n' "$CODE_CHANGED" | sed 's/^/ /' + echo "" + echo " → Tests fehlen oder nicht als STAGED markiert" + echo " → Copilot Chat: /write-tests | Bypass: git commit --no-verify" + ERRORS=$((ERRORS + 1)) +fi + +# ── Check 2: Dokumentation aktualisiert ─────────────────────────────────────── +# Prüfen ob docs/ Verzeichnis überhaupt existiert +if [ -d "docs" ]; then + DOCS_CHANGED=$(printf '%s\n' "$STAGED" \ + | grep -E '(^docs/USER\.md$|^docs/ADMIN\.md$|^docs/MAINTAINER\.md$|^README\.md$)') + + if [ -z "$DOCS_CHANGED" ]; then + echo "" + echo "✗ AGENT QUALITY GATE [2/3]: Keine Dokumentation aktualisiert" + echo " Bei Code-Änderungen muss mindestens eine dieser Dateien angepasst werden:" + echo " docs/USER.md – Nutzer-Dokumentation" + echo " docs/ADMIN.md – Administrator-Dokumentation" + echo " docs/MAINTAINER.md – Entwickler/Maintainer-Dokumentation" + echo " README.md" + echo "" + echo " → Copilot Chat: Frage den Agent die relevante Doku zu aktualisieren" + echo " → Bypass: git commit --no-verify" + ERRORS=$((ERRORS + 1)) + fi +fi + +# ── Check 3: Vollständigkeit der 3 Zielgruppen ──────────────────────────────── +# Nur prüfen wenn docs/ neu angelegt wird (noch nicht vollständig) oder ein +# neues Feature ein neues docs/-File staged hat. +DOCS_DIR_STAGED=$(printf '%s\n' "$STAGED" | grep -E '^docs/' | head -1) + +if [ -n "$DOCS_DIR_STAGED" ] && [ -d "docs" ]; then + MISSING="" + [ ! -f "docs/USER.md" ] && MISSING="${MISSING}\n docs/USER.md (fehlt – für Endnutzer)" + [ ! -f "docs/ADMIN.md" ] && MISSING="${MISSING}\n docs/ADMIN.md (fehlt – für Administratoren)" + [ ! -f "docs/MAINTAINER.md" ] && MISSING="${MISSING}\n docs/MAINTAINER.md (fehlt – für Entwickler)" + + if [ -n "$MISSING" ]; then + echo "" + echo "✗ AGENT QUALITY GATE [3/3]: Fehlende Zielgruppen-Dokumentation" + printf " Nicht vorhanden:%b\n" "$MISSING" + echo "" + echo " Alle 3 Zielgruppen-Dokumente müssen existieren." + echo " Templates: docs/USER.md, docs/ADMIN.md, docs/MAINTAINER.md" + echo " Bypass: git commit --no-verify" + ERRORS=$((ERRORS + 1)) + fi +fi + +# ── Ergebnis ────────────────────────────────────────────────────────────────── +if [ "$ERRORS" -gt 0 ]; then + echo "" + echo "══════════════════════════════════════════════════════════" + echo " $ERRORS von 3 Quality Gate(s) nicht bestanden." + echo " Behebe die Probleme ODER: git commit --no-verify" + echo "══════════════════════════════════════════════════════════" + echo "" + exit 1 +fi + +exit 0 diff --git a/prompts/history.prompt.md b/prompts/history.prompt.md new file mode 100644 index 0000000..2c92b99 --- /dev/null +++ b/prompts/history.prompt.md @@ -0,0 +1,69 @@ +--- +mode: agent +description: Agenten-History loggen oder Kontext-Summary aktualisieren +--- + +# Agent History & Kontext + +Du hilfst dabei die Projekt-History zu pflegen. Es gibt zwei Aufgaben: + +## Aufgabe A: Konversation loggen + +Erstelle eine neue Datei `history/prompts/{{DATUM}}_{{TITEL}}.md` mit folgendem Inhalt: +- Alle Fragen, Antworten, Entscheidungen aus dieser Sitzung +- Datum und Aufgabentitel im Dateinamen (Format: `YYYY-MM-DD_kurz-beschreibung.md`) +- Vollständig – nichts weglassen + +Struktur: +```markdown +# [Aufgabe] – YYYY-MM-DD + +## Aufgabe / Ziel +[Was sollte erreicht werden] + +## Verlauf +### Prompt 1 +[Frage/Anweisung] + +### Antwort 1 +[Was der Agent geantwortet / getan hat] + +### Prompt 2 +… + +## Ergebnis +[Was wurde erreicht? Welche Dateien geändert?] + +## Entscheidungen +[Wichtige Entscheidungen die getroffen wurden] + +## Offene Punkte +[Was wurde nicht abgeschlossen / zurückgestellt?] +``` + +## Aufgabe B: PROJECT_CONTEXT.md aktualisieren + +Lies `history/summary/PROJECT_CONTEXT.md` und aktualisiere: +1. **"Letzte Aktualisierung"** mit heutigem Datum und erledigter Aufgabe +2. **"Erledigte Aufgaben"** – neue Zeile oben einfügen (neueste zuerst) +3. **"Offene Aufgaben"** – Abgehaktes entfernen, Neues hinzufügen +4. **"Für den nächsten Agenten"** – klare Startpunkte für die nächste Session +5. **"Bekannte Fallstricke"** – neue Erkenntnisse ergänzen + +**Wichtig:** `PROJECT_CONTEXT.md` muss immer den aktuellsten Stand widerspiegeln. +Es ist das einzige Dokument, das ein Agent ohne vorherige Kenntnis des Projekts +lesen muss um sofort produktiv zu sein. + +## Wann ausführen? + +- Am **Ende jeder Copilot-Session** die bedeutende Änderungen gemacht hat +- Vor dem **letzten Commit** einer Feature-Branch +- Bevor eine **neue komplexe Aufgabe** beginnt (Kontext prüfen) + +## Automatisierung + +Nach Abschluss dieser Aufgabe: +```bash +git add history/summary/PROJECT_CONTEXT.md +# history/prompts/ ist gitignored – kein add nötig +``` diff --git a/scripts/copilot-bootstrap.sh b/scripts/copilot-bootstrap.sh new file mode 100644 index 0000000..9109c2f --- /dev/null +++ b/scripts/copilot-bootstrap.sh @@ -0,0 +1,127 @@ +#!/usr/bin/env sh +# copilot-bootstrap.sh +# Fügt Copilot-Grundkonfiguration zu einem bestehenden oder neu erstellten Repo hinzu. +# POSIX-kompatibel: läuft auf bash, dash, sh – kein fish nötig. +# +# Usage: +# copilot-bootstrap.sh # aktuelles Verzeichnis +# copilot-bootstrap.sh /path/to/repo # anderes Verzeichnis + +TEMPLATE_DIR="$HOME/.git-templates" +TARGET="${1:-.}" + +if [ ! -d "$TARGET/.git" ]; then + echo "Error: $TARGET is not a git repository" >&2 + exit 1 +fi + +echo "Bootstrapping Copilot config in: $TARGET" + +# .github/copilot-instructions.md +if [ ! -f "$TARGET/.github/copilot-instructions.md" ]; then + mkdir -p "$TARGET/.github" + cp "$TEMPLATE_DIR/.github/copilot-instructions.md" "$TARGET/.github/copilot-instructions.md" + echo " ✓ .github/copilot-instructions.md created (TODO-Felder ausfüllen)" +else + echo " ─ .github/copilot-instructions.md already exists, skipping" +fi + +# .vscode/settings.json +if [ ! -f "$TARGET/.vscode/settings.json" ]; then + mkdir -p "$TARGET/.vscode" + cp "$TEMPLATE_DIR/.vscode/settings.json" "$TARGET/.vscode/settings.json" + echo " ✓ .vscode/settings.json created" +else + echo " ─ .vscode/settings.json already exists, skipping" +fi + +# .vscode/extensions.json +if [ ! -f "$TARGET/.vscode/extensions.json" ]; then + mkdir -p "$TARGET/.vscode" + cp "$TEMPLATE_DIR/.vscode/extensions.json" "$TARGET/.vscode/extensions.json" + echo " ✓ .vscode/extensions.json created" +else + echo " ─ .vscode/extensions.json already exists, skipping" +fi + +# ── data/ – Persistente Service-Daten ──────────────────────────────────────── +if [ ! -d "$TARGET/data" ]; then + mkdir -p "$TARGET/data" + touch "$TARGET/data/.gitkeep" + echo " ✓ data/ created (persistente Service-Daten – gitignored)" +else + echo " ─ data/ already exists, skipping" +fi + +# ── history/ – Agent-History und Kontext-Summary ───────────────────────────── +if [ ! -d "$TARGET/history/prompts" ]; then + mkdir -p "$TARGET/history/prompts" + touch "$TARGET/history/prompts/.gitkeep" + echo " ✓ history/prompts/ created (Agent-Logs – gitignored)" +fi +if [ ! -f "$TARGET/history/summary/PROJECT_CONTEXT.md" ]; then + mkdir -p "$TARGET/history/summary" + cp "$TEMPLATE_DIR/history/summary/PROJECT_CONTEXT.md" "$TARGET/history/summary/PROJECT_CONTEXT.md" + echo " ✓ history/summary/PROJECT_CONTEXT.md created (Agent-Kontext – committed)" +else + echo " ─ history/summary/PROJECT_CONTEXT.md already exists, skipping" +fi + +# ── docs/ – Zielgruppen-Dokumentation ──────────────────────────────────────── +if [ ! -d "$TARGET/docs" ]; then + mkdir -p "$TARGET/docs" + cp "$TEMPLATE_DIR/docs/USER.md" "$TARGET/docs/USER.md" + cp "$TEMPLATE_DIR/docs/ADMIN.md" "$TARGET/docs/ADMIN.md" + cp "$TEMPLATE_DIR/docs/MAINTAINER.md" "$TARGET/docs/MAINTAINER.md" + echo " ✓ docs/ created with USER.md, ADMIN.md, MAINTAINER.md (TODO-Felder ausfüllen)" +else + # Fehlende Zielgruppen-Docs ergänzen ohne vorhandene zu überschreiben + for doc in USER ADMIN MAINTAINER; do + if [ ! -f "$TARGET/docs/${doc}.md" ]; then + cp "$TEMPLATE_DIR/docs/${doc}.md" "$TARGET/docs/${doc}.md" + echo " ✓ docs/${doc}.md created" + else + echo " ─ docs/${doc}.md already exists, skipping" + fi + done +fi + +# ── pre-commit Hook – Agent Quality Gate ───────────────────────────────────── +if [ ! -f "$TARGET/.git/hooks/pre-commit" ]; then + cp "$TEMPLATE_DIR/hooks/pre-commit" "$TARGET/.git/hooks/pre-commit" + chmod +x "$TARGET/.git/hooks/pre-commit" + echo " ✓ .git/hooks/pre-commit installed (Quality Gate: Tests + Docs)" +else + echo " ─ .git/hooks/pre-commit already exists, skipping" +fi + +# ── .gitignore – data/ und history/prompts/ ausschließen ───────────────────── +GITIGNORE="$TARGET/.gitignore" +GITIGNORE_UPDATED=0 + +_append_gitignore() { + if ! grep -qF "$1" "$GITIGNORE" 2>/dev/null; then + printf '\n%s\n%s\n' "$2" "$1" >> "$GITIGNORE" + GITIGNORE_UPDATED=1 + fi +} + +_append_gitignore "data/**/*" "# Persistente Service-Daten (nie committen!)" +_append_gitignore "!data/.gitkeep" "" +_append_gitignore "history/prompts/*" "# Agent-Konversations-Logs (zu groß / zu roh für Git)" +_append_gitignore "!history/prompts/.gitkeep" "" + +if [ "$GITIGNORE_UPDATED" -eq 1 ]; then + echo " ✓ .gitignore aktualisiert (data/, history/prompts/ excluded)" +else + echo " ─ .gitignore already has required entries, skipping" +fi + +echo "" +echo "Done. Nächste Schritte:" +echo " 1. TODO-Felder ausfüllen:" +echo " - .github/copilot-instructions.md" +echo " - history/summary/PROJECT_CONTEXT.md" +echo " - docs/USER.md, docs/ADMIN.md, docs/MAINTAINER.md" +echo " 2. git add .github .vscode docs history/summary .gitignore" +echo " git commit -m 'chore: add copilot workspace config'" diff --git a/scripts/deploy.fish b/scripts/deploy.fish index 491ddff..a04474a 100644 --- a/scripts/deploy.fish +++ b/scripts/deploy.fish @@ -46,20 +46,36 @@ end # ── 4. Git-Templates ────────────────────────────────────────────────────────── set GIT_TEMPLATE_DIR $HOME/.git-templates -mkdir -p $GIT_TEMPLATE_DIR/.github $GIT_TEMPLATE_DIR/.vscode +mkdir -p $GIT_TEMPLATE_DIR/.github $GIT_TEMPLATE_DIR/.vscode \ + $GIT_TEMPLATE_DIR/hooks $GIT_TEMPLATE_DIR/docs \ + $GIT_TEMPLATE_DIR/history/summary cp $REPO_DIR/git-templates/.github/copilot-instructions.md $GIT_TEMPLATE_DIR/.github/ cp $REPO_DIR/git-templates/.vscode/settings.json $GIT_TEMPLATE_DIR/.vscode/ cp $REPO_DIR/git-templates/.vscode/extensions.json $GIT_TEMPLATE_DIR/.vscode/ +cp $REPO_DIR/git-templates/hooks/pre-commit $GIT_TEMPLATE_DIR/hooks/ +chmod +x $GIT_TEMPLATE_DIR/hooks/pre-commit +cp $REPO_DIR/git-templates/docs/USER.md $GIT_TEMPLATE_DIR/docs/ +cp $REPO_DIR/git-templates/docs/ADMIN.md $GIT_TEMPLATE_DIR/docs/ +cp $REPO_DIR/git-templates/docs/MAINTAINER.md $GIT_TEMPLATE_DIR/docs/ +cp $REPO_DIR/git-templates/history/summary/PROJECT_CONTEXT.md $GIT_TEMPLATE_DIR/history/summary/ git config --global init.templateDir $GIT_TEMPLATE_DIR echo " ✓ git-templates deployed → $GIT_TEMPLATE_DIR" echo " ✓ git config init.templateDir set" -# ── 5. Bootstrap-Skript ─────────────────────────────────────────────────────── +# ── 5. Bootstrap-Skripte ────────────────────────────────────────────────────── mkdir -p $HOME/.local/bin +cp $REPO_DIR/scripts/copilot-bootstrap.sh $HOME/.local/bin/copilot-bootstrap.sh +chmod +x $HOME/.local/bin/copilot-bootstrap.sh +echo " ✓ copilot-bootstrap.sh installed to ~/.local/bin/" cp $REPO_DIR/scripts/copilot-bootstrap.fish $HOME/.local/bin/copilot-bootstrap.fish chmod +x $HOME/.local/bin/copilot-bootstrap.fish echo " ✓ copilot-bootstrap.fish installed to ~/.local/bin/" +# ── 6. Git-Alias: git init → auto-bootstrap ─────────────────────────────────── +# Verwendet git --exec-path um Rekursion zu vermeiden (kein Alias-Loop). +git config --global alias.init '!f() { dir=.; for a in "$@"; do case "$a" in -*) ;; *) dir="$a" ;; esac; done; "$(git --exec-path)/git-init" "$@" && "$HOME/.local/bin/copilot-bootstrap.sh" "$dir"; }; f' +echo " ✓ git alias 'init' gesetzt (führt copilot-bootstrap.sh automatisch aus)" + echo "" echo "=== Done ===" echo "Next: Activate Settings Sync in VS Code (Ctrl+Shift+P → 'Settings Sync: Turn On')" diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 8e5c673..12ff4f4 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -46,19 +46,37 @@ done # ── 4. Git-Templates ────────────────────────────────────────────────────────── GIT_TEMPLATE_DIR="$HOME/.git-templates" -mkdir -p "$GIT_TEMPLATE_DIR/.github" "$GIT_TEMPLATE_DIR/.vscode" +mkdir -p "$GIT_TEMPLATE_DIR/.github" "$GIT_TEMPLATE_DIR/.vscode" \ + "$GIT_TEMPLATE_DIR/hooks" "$GIT_TEMPLATE_DIR/docs" \ + "$GIT_TEMPLATE_DIR/history/summary" cp "$REPO_DIR/git-templates/.github/copilot-instructions.md" "$GIT_TEMPLATE_DIR/.github/" cp "$REPO_DIR/git-templates/.vscode/settings.json" "$GIT_TEMPLATE_DIR/.vscode/" cp "$REPO_DIR/git-templates/.vscode/extensions.json" "$GIT_TEMPLATE_DIR/.vscode/" +cp "$REPO_DIR/git-templates/hooks/pre-commit" "$GIT_TEMPLATE_DIR/hooks/" +chmod +x "$GIT_TEMPLATE_DIR/hooks/pre-commit" +cp "$REPO_DIR/git-templates/docs/USER.md" "$GIT_TEMPLATE_DIR/docs/" +cp "$REPO_DIR/git-templates/docs/ADMIN.md" "$GIT_TEMPLATE_DIR/docs/" +cp "$REPO_DIR/git-templates/docs/MAINTAINER.md" "$GIT_TEMPLATE_DIR/docs/" +cp "$REPO_DIR/git-templates/history/summary/PROJECT_CONTEXT.md" "$GIT_TEMPLATE_DIR/history/summary/" git config --global init.templateDir "$GIT_TEMPLATE_DIR" echo " ✓ git-templates deployed → $GIT_TEMPLATE_DIR" echo " ✓ git config init.templateDir set" -# ── 5. Bootstrap-Skript ─────────────────────────────────────────────────────── +# ── 5. Bootstrap-Skripte ───────────────────────────────────────────────────── mkdir -p "$HOME/.local/bin" -cp "$REPO_DIR/scripts/copilot-bootstrap.fish" "$HOME/.local/bin/copilot-bootstrap.fish" -chmod +x "$HOME/.local/bin/copilot-bootstrap.fish" -echo " ✓ copilot-bootstrap.fish installed to ~/.local/bin/" +cp "$REPO_DIR/scripts/copilot-bootstrap.sh" "$HOME/.local/bin/copilot-bootstrap.sh" +chmod +x "$HOME/.local/bin/copilot-bootstrap.sh" +echo " ✓ copilot-bootstrap.sh installed to ~/.local/bin/" +if [[ -f "$REPO_DIR/scripts/copilot-bootstrap.fish" ]]; then + cp "$REPO_DIR/scripts/copilot-bootstrap.fish" "$HOME/.local/bin/copilot-bootstrap.fish" + chmod +x "$HOME/.local/bin/copilot-bootstrap.fish" + echo " ✓ copilot-bootstrap.fish installed to ~/.local/bin/" +fi + +# ── 6. Git-Alias: git init → auto-bootstrap ────────────────────────────────── +# Verwendet git --exec-path um Rekursion zu vermeiden (kein Alias-Loop). +git config --global alias.init '!f() { dir=.; for a in "$@"; do case "$a" in -*) ;; *) dir="$a" ;; esac; done; "$(git --exec-path)/git-init" "$@" && "$HOME/.local/bin/copilot-bootstrap.sh" "$dir"; }; f' +echo " ✓ git alias 'init' gesetzt (führt copilot-bootstrap.sh automatisch aus)" echo "" echo "=== Done ==="