diff --git a/.github/prompts/genome.prompt.md b/.github/prompts/genome.prompt.md index cdb702e..c064149 100644 --- a/.github/prompts/genome.prompt.md +++ b/.github/prompts/genome.prompt.md @@ -6,7 +6,7 @@ tools: [read, edit, search, execute] # Genome Engine -> **Skill-Referenz:** Lies `.github/skills/genome/SKILL.md` für das vollständige Konzept. +> **Konzept-Dokument:** `docs/genome-engine.md` · **Skill-Doku:** `.github/skills/genome/SKILL.md` Du orchestrierst die 3 Phasen der Genome Engine: **Extraction → Distillation → Propagation**. diff --git a/.github/skills/genome/SKILL.md b/.github/skills/genome/SKILL.md index d0eedf3..84ffec9 100644 --- a/.github/skills/genome/SKILL.md +++ b/.github/skills/genome/SKILL.md @@ -36,10 +36,14 @@ Der Router-Prompt fragt nach Quell-Repo und Zeitspanne, dann orchestriert er all ## Dateien -| Datei | Zweck | -| ------------------- | --------------------------------------- | -| `SKILL.md` | Diese Dokumentation | -| `genome-extract.py` | Phase 1: Git-Scanning + Trait-Erkennung | +| Datei | Ort | Zweck | +| -------------------------------------------- | ---------------------- | --------------------------------------- | +| `SKILL.md` | `.github/skills/genome/` | Diese Dokumentation | +| `genome-extract.py` | `.github/skills/genome/` | Phase 1: Git-Scanning + Trait-Erkennung | +| `genome.prompt.md` | `.github/prompts/` | Orchestrator (Router für alle 3 Phasen) | +| `genome-distill.prompt.md` | `.github/prompts/` | Phase 2: Klassifizierung + Scoring | +| `genome-propagate.prompt.md` | `.github/prompts/` | Phase 3: Patch-Generierung für Ziel | +| `genome-engine.md` | `docs/` | Vollständiges Konzept-Dokument | ## Trait-Erkennung diff --git a/.github/skills/genome/genome-extract.py b/.github/skills/genome/genome-extract.py index 2bf198b..1cff82e 100644 --- a/.github/skills/genome/genome-extract.py +++ b/.github/skills/genome/genome-extract.py @@ -27,9 +27,11 @@ GENOME_SCOPES = [ ".github/agents/", ".github/prompts/", ".github/copilot-instructions.md", - ".github/kotlin-conventions.instructions.md", ] +# Dynamisches Pattern für weitere Instructions-Dateien +INSTRUCTIONS_PATTERN = re.compile(r"^\.github/[^/]+\.instructions\.md$") + MAX_DIFF_LINES = 80 @@ -55,6 +57,9 @@ def is_in_genome_scope(filepath: str) -> bool: else: if filepath == scope: return True + # Dynamisch: .github/*.instructions.md + if INSTRUCTIONS_PATTERN.match(filepath): + return True return False diff --git a/docs/genome-engine.md b/docs/genome-engine.md index 1a67c94..3e5f812 100644 --- a/docs/genome-engine.md +++ b/docs/genome-engine.md @@ -4,10 +4,32 @@ Automatische Erkennung evolutionärer Verbesserungen an Copilot-Customization-Dateien (Skills, Agents, Prompts, Instructions) über Git-History hinweg. Die erkannten Verbesserungen werden destilliert, bewertet und als Propagation-Vorschläge für andere Projekte bereitgestellt. +```mermaid +graph LR + A[Repo A
Verbesserungen] -->|Git-History| E[Extraction] + E -->|raw-mutations| D[Distillation] + D -->|Growth Vectors| P[Propagation] + P -->|Patches| B[Repo B
aktualisiert] +``` + --- ## Begriffe +```mermaid +graph TD + G[🧬 Genome
Gesamtheit aller Traits] --> T1[Trait: Skill] + G --> T2[Trait: Agent] + G --> T3[Trait: Prompt] + G --> T4[Trait: Instructions] + T1 -->|Git-Delta| M1[Mutation] + T3 -->|Git-Delta| M2[Mutation] + M1 -->|destilliert| GV1[Growth Vector
Score 8/10 🟡] + M2 -->|destilliert| GV2[Growth Vector
Score 9/10 🔴] + GV1 --> PR[Propagation
Konkrete Patches] + GV2 --> PR +``` + | Begriff | Bedeutung | | ----------------- | ----------------------------------------------------------------------------------------- | | **Trait** | Ein Skill, Agent, Prompt(-Verbund) oder Instructions-File inkl. aller zugehörigen Dateien | @@ -26,6 +48,7 @@ Folgende Pfade bilden das Genome: - `.github/agents/**` - `.github/prompts/**` - `.github/copilot-instructions.md` +- `.github/*.instructions.md` --- @@ -33,6 +56,17 @@ Folgende Pfade bilden das Genome: Traits werden aus dem Dateipfad abgeleitet. Die Granularität hängt vom Trait-Typ ab: +```mermaid +graph TD + F[Dateipfad] --> S{Pfad-Pattern?} + S -->|.github/skills/X/...| SK["skill/X"] + S -->|.github/agents/X.agent.md| AG["agent/X"] + S -->|.github/prompts/X.prompt.md| PM{Verbund?} + S -->|.github/*.instructions.md| IN["instructions/X"] + PM -->|"X-*.prompt.md existiert"| VB["prompt/X
(Verbund)"] + PM -->|Keine Sub-Prompts| SA["prompt/X
(Standalone)"] +``` + ### Skills Ein Skill besteht aus einem Ordner mit mehreren zusammengehörigen Dateien (SKILL.md, Scripte, Templates). Der **Ordnername** ist der Trait-Schlüssel. @@ -69,7 +103,6 @@ Einzeldateien ohne Router-Beziehung. Der **Dateiname** ist der Trait-Schlüssel. .github/prompts/commit.prompt.md → trait: prompt/commit .github/prompts/ship.prompt.md → trait: prompt/ship .github/prompts/publish.prompt.md → trait: prompt/publish -.github/prompts/clean.prompt.md → trait: prompt/clean ``` **Regel:** `prompt/` – 1:1-Zuordnung Datei → Trait. @@ -81,25 +114,19 @@ Wenn eine Prompt-Datei eine Routing-Tabelle mit Verweisen auf andere `.prompt.md ``` .github/prompts/nextstep.prompt.md → trait: prompt/nextstep .github/prompts/nextstep-implementation.prompt.md → trait: prompt/nextstep -.github/prompts/nextstep-infrastructure.prompt.md → trait: prompt/nextstep .github/prompts/nextstep-planning.prompt.md → trait: prompt/nextstep -.github/prompts/nextstep-block-planning.prompt.md → trait: prompt/nextstep .github/prompts/nextstep-tech-decision.prompt.md → trait: prompt/nextstep -.github/prompts/nextstep-test.prompt.md → trait: prompt/nextstep ``` -**Regel:** `prompt/` – Router (`.prompt.md`) + alle `-*.prompt.md`-Dateien gehören zum selben Trait. - -**Begründung:** Der gesamte Workflow (Router + Sub-Prompts) ist semantisch eine Einheit (~300 Zeilen). Ein neuer Sub-Workflow ist nur im Kontext des Routers sinnvoll. Bei Propagation muss der Agent immer Router + Sub-Prompts zusammen betrachten. - -**Verbund-Erkennung (Namenskonvention):** Eine Datei `.prompt.md` ist ein Router, wenn Dateien `-*.prompt.md` im selben Verzeichnis existieren. Alle `-*.prompt.md`-Dateien gehören zum selben Verbund-Trait. +**Verbund-Erkennung:** Eine Datei `.prompt.md` ist ein Router, wenn Dateien `-*.prompt.md` im selben Verzeichnis existieren. Alle gehören zum selben Verbund-Trait. ### Instructions Instructions-Dateien sind Einzeldateien. Der **Dateiname** ist der Trait-Schlüssel. ``` -.github/copilot-instructions.md → trait: instructions/copilot-instructions +.github/copilot-instructions.md → trait: instructions/copilot-instructions +.github/kotlin-conventions.instructions.md → trait: instructions/kotlin-conventions ``` **Regel:** `instructions/` – 1:1-Zuordnung Datei → Trait. @@ -108,41 +135,69 @@ Instructions-Dateien sind Einzeldateien. Der **Dateiname** ist der Trait-Schlüs ## Mutation-Typen -Jede Mutation wird mit einem Typ klassifiziert: - -| Typ | Bedeutung | Beispiel | -| ---------------- | ------------------------------------ | ------------------------------------------------------------ | -| `content-change` | Inhalt einer Datei im Trait geändert | `nextstep-implementation.prompt.md` optimiert | -| `member-added` | Neue Datei zum Trait hinzugefügt | Neuer `nextstep-migration.prompt.md` + Router-Eintrag | -| `member-removed` | Datei aus dem Trait entfernt | `nextstep-test.prompt.md` gelöscht + Router-Eintrag entfernt | - -Bei **Verbund-Traits** umfasst `member-added`/`member-removed` immer die betroffene Sub-Datei **und** die Router-Anpassung als zusammenhängende Mutation. Bei **Standalone-Traits** und **Skills** entspricht `member-added` dem Anlegen einer neuen Datei im Trait-Ordner. +| Typ | Bedeutung | Beispiel | +| ---------------- | ------------------------------------ | ----------------------------------------------------- | +| `content-change` | Inhalt einer Datei im Trait geändert | `nextstep-implementation.prompt.md` optimiert | +| `member-added` | Neue Datei zum Trait hinzugefügt | Neuer `nextstep-migration.prompt.md` + Router-Eintrag | +| `member-removed` | Datei aus dem Trait entfernt | `nextstep-test.prompt.md` gelöscht | --- ## Pipeline +```mermaid +flowchart LR + subgraph "Phase 1: Extraction" + direction TB + GIT[(Git-History)] --> SCRIPT[genome-extract.py] + SCRIPT --> RAW[raw-mutations.md] + end + subgraph "Phase 2: Distillation" + direction TB + RAW2[raw-mutations.md] --> AGENT1[KI-Agent] + AGENT1 --> |"Klassifizieren\nScoren\nSanitizen"| DIST[distilled-mutations.md] + end + subgraph "Phase 3: Propagation" + direction TB + DIST2[distilled-mutations.md] --> AGENT2[KI-Agent] + ZIEL[Ziel-Genome] --> AGENT2 + AGENT2 --> PATCHES[Konkrete Patches] + end + RAW --> RAW2 + DIST --> DIST2 +``` + ### Phase 1: Extraction (Script) -**Input:** Repo-Pfad + Zeitspanne (z.B. `--since "4 days ago"`) +**Input:** Repo-Pfad + Zeitspanne (z.B. `--since "7 days ago"`) **Output:** `raw-mutations.md` - Scannt `git log` für Änderungen im Genome-Scope - Gruppiert Diffs nach Trait (siehe Trait-Erkennung oben) - Gibt pro Trait alle Commits mit Diff, Message und Autor aus -**Tool:** `genome-extract.ps1` +**Tool:** `genome-extract.py` (Python) ### Phase 2: Distillation (Agent) **Input:** `raw-mutations.md` **Output:** `distilled-mutations.md` -- Klassifiziert jede Mutation: - - 🔴 **Critical** – Bugfixes, die andere auch treffen - - 🟡 **Evolution** – Generelle Verbesserungen (bessere Prompts, neue Patterns) - - ⚪ **Specialized** – Projektspezifisch, nicht übertragbar -- Scored jede Mutation (1–10) +```mermaid +flowchart TD + M[Mutation] --> K{Klassifizierung} + K -->|Bugfix für alle| C[🔴 Critical] + K -->|Generelle Verbesserung| E[🟡 Evolution] + K -->|Nur dieses Projekt| S[⚪ Specialized] + C --> SC[Score 1–10] + E --> SC + S --> X[❌ Entfernt] + SC --> SAN[Sanitization
Pfade, Tokens, IDs ersetzen] + SAN --> |Score ≥ 4| OUT[→ distilled-mutations.md] + SAN --> |Score < 4| X +``` + +- Scored jede Mutation (1–10) nach Übertragungswert - Filtert sensitive Daten (Usernames, Maschinenpfade, Tokens, projektspezifische IDs) - Specialized Mutations werden komplett entfernt @@ -150,17 +205,19 @@ Bei **Verbund-Traits** umfasst `member-added`/`member-removed` immer die betroff ### Phase 3: Propagation (Agent) -**Input:** `distilled-mutations.md` + Ziel-Genome (`.github/` des Ziel-Repos) +**Input:** `distilled-mutations.md` + Ziel-Genome **Output:** `propagation-proposals.md` - Matched Traits zwischen Quell- und Ziel-Genome - Erstellt konkrete Änderungsvorschläge pro Trait -- Formatiert als Checkliste: - - `[x]` Critical (default an) - - `[x]` Evolution mit Score ≥ 7 (default an) - - `[ ]` Evolution mit Score < 7 (default aus) - - Specialized taucht nicht auf (bereits gefiltert) -- User wählt aus, Agent wendet ausgewählte Patches an +- Formatiert als Checkliste mit Default-Auswahl: + +| Kategorie | Default | Bedingung | +| ------------------ | ------- | ---------- | +| 🔴 Critical | ✅ an | immer | +| 🟡 Evolution ≥ 7 | ✅ an | Score ≥ 7 | +| 🟡 Evolution < 7 | ❌ aus | Score < 7 | +| ⚪ Specialized | — | gefiltert | **Tool:** `genome-propagate.prompt.md` @@ -168,26 +225,66 @@ Bei **Verbund-Traits** umfasst `member-added`/`member-removed` immer die betroff ## Zeitbasierte Transferlogik -Die Zeitspanne bestimmt, welche Mutations extrahiert werden: +```mermaid +sequenceDiagram + participant R as Quell-Repo + participant T as Ziel-Repo + Note over T: Letzter .github/-Commit = T_target + R->>R: git log --since T_target + R->>R: 12 Commits an .github/ gefunden + R-->>T: Mutations extrahiert → Distillation → Propagation +``` 1. Letzter `.github/`-Commit im Ziel-Repo ermitteln → `T_target` 2. Alle `.github/`-Commits im Quell-Repo seit `T_target` extrahieren 3. Das Delta zwischen `T_target` und jetzt ist der Evolutionszeitraum -**Beispiel:** bollwerk hat `.github/` zuletzt vor 4 Tagen von hva übernommen. Seitdem gab es 12 Commits an `.github/` in bollwerk. Diese 12 Commits sind die Mutations. - --- -## Deliverables +## Dateistruktur -| # | Datei | Typ | Ort | -| --- | ---------------------------- | ----------------- | ------------------------ | -| 1 | `genome-extract.ps1` | PowerShell Script | `.github/genome/` | -| 2 | `genome-distill.prompt.md` | Prompt | `.github/genome/` | -| 3 | `genome-propagate.prompt.md` | Prompt | `.github/genome/` | -| 4 | `raw-mutations.md` | Generiert | `.github/genome/output/` | -| 5 | `distilled-mutations.md` | Generiert | `.github/genome/output/` | -| 6 | `propagation-proposals.md` | Generiert | `.github/genome/output/` | +```mermaid +graph TD + subgraph ".github/skills/genome/" + SK[SKILL.md
Skill-Dokumentation] + EX[genome-extract.py
Phase 1 Script] + end + subgraph ".github/prompts/" + OR[genome.prompt.md
Orchestrator] + DI[genome-distill.prompt.md
Phase 2] + PR[genome-propagate.prompt.md
Phase 3] + end + subgraph ".github/genome/output/" + RM[raw-mutations.md
generiert] + DM[distilled-mutations.md
generiert] + PP[propagation-proposals.md
generiert] + end + subgraph "docs/" + CO[genome-engine.md
Dieses Konzept] + end + OR -->|"ruft auf"| EX + OR -->|"delegiert an"| DI + OR -->|"delegiert an"| PR + EX -->|"schreibt"| RM + DI -->|"liest"| RM + DI -->|"schreibt"| DM + PR -->|"liest"| DM + PR -->|"schreibt"| PP +``` + +| # | Datei | Typ | Ort | +| --- | ---------------------------- | ------------- | -------------------------- | +| 1 | `genome-extract.py` | Python Script | `.github/skills/genome/` | +| 2 | `genome.prompt.md` | Orchestrator | `.github/prompts/` | +| 3 | `genome-distill.prompt.md` | Prompt | `.github/prompts/` | +| 4 | `genome-propagate.prompt.md` | Prompt | `.github/prompts/` | +| 5 | `SKILL.md` | Skill-Doku | `.github/skills/genome/` | +| 6 | `genome-engine.md` | Konzept | `docs/` | +| 7 | `raw-mutations.md` | Generiert | `.github/genome/output/` | +| 8 | `distilled-mutations.md` | Generiert | `.github/genome/output/` | +| 9 | `propagation-proposals.md` | Generiert | `.github/genome/output/` | + +> Generierte Dateien (7–9) sind gitignored. ---