rd13_copilot_setup/scripts/copilot-bootstrap.sh
Conrad Schulz 045e2e7202 feat: add data/, history/, 3-target-group docs, pre-commit quality gate
- New repo convention: /data/<service>/ 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
2026-05-30 17:19:52 +00:00

127 lines
5.1 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/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'"