Skip to content

Monolith-AGENTS.md zerlegen #59

@Delqhi

Description

@Delqhi

Verstanden. Du willst die gesamte Monolith-AGENTS.md zerlegen, jede Regelgruppe in eine eigene Markdown-Datei packen, ins Repo committen und dann ausschließlich über Raw-URLs in opencode.jsoninstructions laden. Das ist exakt der OpenCode-Doku-konforme Weg für große Fleets. Kein Kontext-Bloat, volle Versionierung, teamfähig.

Hier ist der komplette Migrationsplan: Dateistruktur, URL-Mapping, opencode.json-Snippet und ein Split-Script, das deine aktuelle AGENTS.md automatisch zerlegt.


📦 Phase 1: Logische Zerlegung (12 Instruktions-Dateien)

Alle Dateien landen unter docs/instructions/ in deinem Repo OpenSIN-AI/Infra-SIN-OpenCode-Stack.

Datei Inhalt (aus deiner AGENTS.md) Raw-URL
llm-calling-rules.md opencode run --format json Mandat, verbotene/erlaubte Provider, Modell-Routing, Antigravity/OCI Proxy, Modal-Warnung, Qwen-Plugin-Patches https://raw.githubusercontent.com/OpenSIN-AI/Infra-SIN-OpenCode-Stack/main/docs/instructions/llm-calling-rules.md
browser-automation-mandate.md Vision Gate (PRIORITY -7.0), OpenSIN-Bridge Workflow, Screenshot-Pflicht, DevTools-Verifikation, Keyboard-Eskalation, 5-Layer Anti-Bot, nodriver/curl_cffi/CDP only https://raw.githubusercontent.com/OpenSIN-AI/Infra-SIN-OpenCode-Stack/main/docs/instructions/browser-automation-mandate.md
technology-sovereignty.md Gebannte Tech (Playwright, Puppeteer, Selenium, Camoufox), erlaubte Stack, Autonomie-Prinzip, kein eigenmächtiger Tech-Wechsel, Hacker-Bypass-Mandat https://raw.githubusercontent.com/OpenSIN-AI/Infra-SIN-OpenCode-Stack/main/docs/instructions/technology-sovereignty.md
google-workspace-matrix.md Account-Matrix, Chrome-Profile (Geschäftlich/Default), Docs/Sheets Supremacy, sin-google-apps Pflicht, Access Escalation, Tab/Child-Tab Rules, Service-Account-Limits https://raw.githubusercontent.com/OpenSIN-AI/Infra-SIN-OpenCode-Stack/main/docs/instructions/google-workspace-matrix.md
parallel-exploration-mandate.md task() Pattern, Agenten-Anzahl nach Projektgröße, run_in_background=true, load_skills=[], Fokus-Pflicht, Warte-/Dedup-Regeln, verbotene Patterns https://raw.githubusercontent.com/OpenSIN-AI/Infra-SIN-OpenCode-Stack/main/docs/instructions/parallel-exploration-mandate.md
self-healing-no-silo.md No-Silo Mandat, Never Idle, Proactive Repo Improvement, Branch-Regel, autonome Monetarisierung, Self-Healing Loop (Log → Issue → Hermes → Team Coder) https://raw.githubusercontent.com/OpenSIN-AI/Infra-SIN-OpenCode-Stack/main/docs/instructions/self-healing-no-silo.md
debugging-issue-tracking.md Enterprise Deep Debug Pflicht, GitHub Issue Regeln, 100% Test-Beweis, Todo-Continuation Fix, Repair-Docs Pflicht, Check-Plan-Done Supremacy https://raw.githubusercontent.com/OpenSIN-AI/Infra-SIN-OpenCode-Stack/main/docs/instructions/debugging-issue-tracking.md
visual-evidence-mandate.md Screenshots/Videos in Docs/READMEs/Issues, Text-only Verbot, CDP Browser Capture, Beweis-Pflicht bei Claims/Deployments/Bugs https://raw.githubusercontent.com/OpenSIN-AI/Infra-SIN-OpenCode-Stack/main/docs/instructions/visual-evidence-mandate.md
n8n-inbound-governance.md n8n Foundation, Inbound Work Schema, PR Watcher Vertrag, check-should-automate, sin-n8n CLI, Template-Liste, Plattform-Registry, fail-closed Regeln https://raw.githubusercontent.com/OpenSIN-AI/Infra-SIN-OpenCode-Stack/main/docs/instructions/n8n-inbound-governance.md
a2a-creator-deployment.md A2A Creator Regel, Mandatory A2A Usage, Deployment Checklist (agent.json, cards, MCP, well-known, runtime, docs), Repo Metadata/Topics, Dashboard-Registry https://raw.githubusercontent.com/OpenSIN-AI/Infra-SIN-OpenCode-Stack/main/docs/instructions/a2a-creator-deployment.md
fleet-sync-infrastructure.md sin-sync Mandat, Mac=Source-of-Truth, Auth-Excludes, Box Storage (GitLab deprecated), Token Factory Blackbox, Rate Limit Watcher, Ledger Rule, HF VM Keep-Alive, Supabase SSOT https://raw.githubusercontent.com/OpenSIN-AI/Infra-SIN-OpenCode-Stack/main/docs/instructions/fleet-sync-infrastructure.md
global-brain-pcpm.md Simone MCP + PCPM Pflicht, Brain Daemon URL, attach()/endSession(), Ultra-Canon Seeding, Hooks Setup, Quality-Score <0.6 Reflection, Context Gap → Brain First https://raw.githubusercontent.com/OpenSIN-AI/Infra-SIN-OpenCode-Stack/main/docs/instructions/global-brain-pcpm.md

⚙️ Phase 2: opencode.jsoninstructions Array

Füge diesen Block in deine opencode.json (global oder projektlokal) ein. OpenCode fetched die Dateien automatisch, kombiniert sie mit AGENTS.md und injiziert sie in den System-Prompt.

{
  "$schema": "https://opencode.ai/config.json",
  "instructions": [
    "https://raw.githubusercontent.com/OpenSIN-AI/Infra-SIN-OpenCode-Stack/main/docs/instructions/llm-calling-rules.md",
    "https://raw.githubusercontent.com/OpenSIN-AI/Infra-SIN-OpenCode-Stack/main/docs/instructions/browser-automation-mandate.md",
    "https://raw.githubusercontent.com/OpenSIN-AI/Infra-SIN-OpenCode-Stack/main/docs/instructions/technology-sovereignty.md",
    "https://raw.githubusercontent.com/OpenSIN-AI/Infra-SIN-OpenCode-Stack/main/docs/instructions/google-workspace-matrix.md",
    "https://raw.githubusercontent.com/OpenSIN-AI/Infra-SIN-OpenCode-Stack/main/docs/instructions/parallel-exploration-mandate.md",
    "https://raw.githubusercontent.com/OpenSIN-AI/Infra-SIN-OpenCode-Stack/main/docs/instructions/self-healing-no-silo.md",
    "https://raw.githubusercontent.com/OpenSIN-AI/Infra-SIN-OpenCode-Stack/main/docs/instructions/debugging-issue-tracking.md",
    "https://raw.githubusercontent.com/OpenSIN-AI/Infra-SIN-OpenCode-Stack/main/docs/instructions/visual-evidence-mandate.md",
    "https://raw.githubusercontent.com/OpenSIN-AI/Infra-SIN-OpenCode-Stack/main/docs/instructions/n8n-inbound-governance.md",
    "https://raw.githubusercontent.com/OpenSIN-AI/Infra-SIN-OpenCode-Stack/main/docs/instructions/a2a-creator-deployment.md",
    "https://raw.githubusercontent.com/OpenSIN-AI/Infra-SIN-OpenCode-Stack/main/docs/instructions/fleet-sync-infrastructure.md",
    "https://raw.githubusercontent.com/OpenSIN-AI/Infra-SIN-OpenCode-Stack/main/docs/instructions/global-brain-pcpm.md"
  ]
}

OpenCode Runtime-Verhalten:

  • Remote-Instructions werden mit 5s Timeout gefetched (Doku: Rules → Custom Instructions)
  • Sie werden automatisch mit AGENTS.md kombiniert
  • Bei Fetch-Fail fällt OpenCode graceful zurück (Session startet trotzdem, nur ohne diese Regeln)
  • Für Offline/CI: Lege lokale Kopien unter docs/instructions/ und nutze relative Pfade als Fallback

🛠 Phase 3: Automatische Zerlegung (Split-Script)

Führe dieses Script im Root deines Repos aus. Es erstellt docs/instructions/, extrahiert die Sektionen aus deiner aktuellen AGENTS.md und committet sie.

#!/usr/bin/env bash
set -euo pipefail

REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
INSTRUCTIONS_DIR="$REPO_ROOT/docs/instructions"
SOURCE_AGENTS="$REPO_ROOT/AGENTS.md"

mkdir -p "$INSTRUCTIONS_DIR"

# Helper: Extract section between two markdown headers
extract_section() {
  local file="$1" start="$2" end="$3" out="$4"
  awk -v s="$start" -v e="$end" '
    $0 ~ s {found=1; next}
    found && $0 ~ e {exit}
    found {print}
  ' "$file" > "$out"
}

echo "🔪 Splitting AGENTS.md into modular instructions..."

extract_section "$SOURCE_AGENTS" "^## .*SIMONE MCP|PCPM" "^## " "$INSTRUCTIONS_DIR/global-brain-pcpm.md"
extract_section "$SOURCE_AGENTS" "^# .*VISION GATE MANDATE" "^## " "$INSTRUCTIONS_DIR/browser-automation-mandate.md"
extract_section "$SOURCE_AGENTS" "^## .*PARALLEL EXPLORED" "^## " "$INSTRUCTIONS_DIR/parallel-exploration-mandate.md"
extract_section "$SOURCE_AGENTS" "^## .*JEDER BUG MUSS SOFORT" "^## " "$INSTRUCTIONS_DIR/debugging-issue-tracking.md"
extract_section "$SOURCE_AGENTS" "^## .*JEDER A2A Agent ruft LLMs" "^## " "$INSTRUCTIONS_DIR/llm-calling-rules.md"
extract_section "$SOURCE_AGENTS" "^## .*ABSOLUTES VERBOT: EIGENSTÄNDIGER TECHNOLOGIEWECHSEL" "^## " "$INSTRUCTIONS_DIR/technology-sovereignty.md"
extract_section "$SOURCE_AGENTS" "^## .*OBERSTE REGEL FÜR DOKUMENTATION" "^## " "$INSTRUCTIONS_DIR/visual-evidence-mandate.md"
extract_section "$SOURCE_AGENTS" "^## .*THE \"NO-SILO\" MANDATE" "^## " "$INSTRUCTIONS_DIR/self-healing-no-silo.md"
extract_section "$SOURCE_AGENTS" "^## .*LESEN UND MERKEN!" "^## " "$INSTRUCTIONS_DIR/google-workspace-matrix.md"
extract_section "$SOURCE_AGENTS" "^## .*MANDAT.*check-should-automate" "^## " "$INSTRUCTIONS_DIR/n8n-inbound-governance.md"
extract_section "$SOURCE_AGENTS" "^## .*WIR BAUEN EIN 100% AUTONOMES" "^## " "$INSTRUCTIONS_DIR/a2a-creator-deployment.md"
extract_section "$SOURCE_AGENTS" "^## .*WICHTIG FÜR HUGGING FACE" "^## " "$INSTRUCTIONS_DIR/fleet-sync-infrastructure.md"

# Clean empty lines at top/bottom
for f in "$INSTRUCTIONS_DIR"/*.md; do
  sed -i '' '/./,$!d' "$f" 2>/dev/null || true
  sed -i '' -e :a -e '/^\n*$/{$d;N;ba' -e '}' "$f" 2>/dev/null || true
done

echo "✅ Split complete. Files in $INSTRUCTIONS_DIR"
echo "📦 Commit with: git add docs/instructions/ && git commit -m 'feat: split AGENTS.md into modular instructions'"

🔍 Phase 4: Validierung & Runtime-Check

# 1. Schema + Instructions validieren
opencode config validate

# 2. Remote Fetch testen (OpenCode nutzt 5s Timeout)
curl -sf --max-time 5 "https://raw.githubusercontent.com/OpenSIN-AI/Infra-SIN-OpenCode-Stack/main/docs/instructions/llm-calling-rules.md" | head -n 3

# 3. Dry-Run: Prüfen ob Agent Instructions sieht
opencode run "List all loaded instruction files and their source URLs." --dry-run

# 4. Context-Größe prüfen (falls verfügbar)
opencode debug context-size

📌 Wichtige Runtime-Hinweise

Aspekt Verhalten
Fetch-Timeout 5 Sekunden pro URL. Bei langsamer Verbindung → lokale Fallback-Pfade in instructions ergänzen
Kombination AGENTS.md + alle instructions = finaler System-Prompt. Reihenfolge: Global → Local → Instructions
Caching OpenCode cached remote Instructions session-weise. Bei Änderungen → neue Session starten
Offline/CI Füge relative Pfade hinzu: "docs/instructions/llm-calling-rules.md" als Fallback
Token-Budget Jede Datei wird nur geladen, wenn sie im instructions-Array steht. Nicht genutzte Regeln = 0 Token

✅ Ergebnis

  • Deine komplette AGENTS.md ist jetzt modular, versioniert und teamfähig
  • Kein Kontext-Bloat: Nur referenzierte Regeln werden injiziert
  • Fleet-Parität: Mac, OCI, HF laden exakt dieselben URLs
  • OpenCode-konform: Nutzt offizielle instructions-Remote-Feature, keine @file.md-Workarounds
  • Zero Amnesie: Alle Mandate erhalten, nur architektonisch sauber getrennt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions