Skill: mrnsmh/nexus-brain (version 0.1.1)

# Skill: Nexus-Orchestrator (V1.1) Intelligent SRE Bridge for AI-driven system diagnosis and recovery. ## 🛡️ Security & Privacy Protocols - **Log Redaction**: The orchestrator includes a redaction engine that masks passwords, tokens, and emails in logs before sending them to the reasoning service. - **Generic Binary Support**: No longer relies on root-home paths. It searches for `opencode` in your system PATH or local user directory. - **Privacy Notice**: This skill sends redacted log snippets to your configured AI reasoning service (e.g., OpenCode/Codex). Ensure your AI provider complies with your data policy. ## 📋 Capabilities - **Reasoning-First Recovery**: Blocks blind restarts. Analyzes logs to differentiate between code bugs (alert user) and infra failures (restart service). - **Log Contextualization**: Automatically fetches and redacts relevant logs for the AI. ## ⚙️ Logic & Safeguards - **Manual Oversight**: Critical actions still require `/approve` if configured in OpenClaw. - **Diagnostic Step**: The agent is forced to perform an analysis via `bridge.py` before any recovery action. ## 🚀 Installation 1. `pip install psutil` 2. Ensure `docker`, `pm2`, and `opencode` are installed.

path: _meta.json
content: {
  "name": "nexus-orchestrator",
  "description": "AI-Driven SRE Orchestrator. Connects local diagnostics with AI reasoning for logical self-healing and log analysis.",
  "version": "1.1.0",
  "author": "mrnsmh",
  "entrypoint": "SKILL.md",
  "requirements": {
    "binaries": ["docker", "pm2", "opencode"],
    "pythonPackages": ["psutil"]
  },
  "permissions": {
    "filesystem": ["read", "write:~/.nexus-safe/"],
    "network": ["outbound:opencode.ai"],
    "commands": ["docker", "pm2", "opencode"]
  }
}


path: bridge.py
content: import subprocess
import sys
import os
import re

def redact_logs(text):
    """Simple regex to mask potential secrets in logs before AI analysis."""
    patterns = [
        (r'([Pp]assword|[Ss]ecret|[Tt]oken|[Aa]pi[Kk]ey)["\s:=]+[^\s,"]+', r'\1: [REDACTED]'),
        (r'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}', '[EMAIL_REDACTED]')
    ]
    for pattern, replacement in patterns:
        text = re.sub(pattern, replacement, text)
    return text

def ask_orchestrator(prompt, target_binary="opencode"):
    # First, try to find the binary in PATH, then fallback to user home
    opencode_path = subprocess.run(["which", target_binary], capture_output=True, text=True).stdout.strip()
    if not opencode_path:
        opencode_path = os.path.expanduser("~/.opencode/bin/opencode")

    if not os.path.exists(opencode_path):
        return f"Error: {target_binary} binary not found in PATH or ~/.opencode/bin/"

    try:
        # Sanitize prompt (basic)
        safe_prompt = redact_logs(prompt)
        res = subprocess.run([opencode_path, "run", safe_prompt], capture_output=True, text=True, timeout=60)
        return res.stdout if res.returncode == 0 else f"AI Error: {res.stderr}"
    except Exception as e:
        return f"Orchestrator Bridge Error: {str(e)}"

if __name__ == "__main__":
    if len(sys.argv) > 1:
        print(ask_orchestrator(" ".join(sys.argv[1:])))
    else:
        print("Usage: python3 bridge.py 'prompt'")


path: README.md
content: # Skill: Nexus-Orchestrator (V1.1)

Intelligent SRE Bridge for AI-driven system diagnosis and recovery.

## 🛡️ Security & Privacy Protocols
- **Log Redaction**: The orchestrator includes a redaction engine that masks passwords, tokens, and emails in logs before sending them to the reasoning service.
- **Generic Binary Support**: No longer relies on root-home paths. It searches for `opencode` in your system PATH or local user directory.
- **Privacy Notice**: This skill sends redacted log snippets to your configured AI reasoning service (e.g., OpenCode/Codex). Ensure your AI provider complies with your data policy.

## 📋 Capabilities
- **Reasoning-First Recovery**: Blocks blind restarts. Analyzes logs to differentiate between code bugs (alert user) and infra failures (restart service).
- **Log Contextualization**: Automatically fetches and redacts relevant logs for the AI.

## ⚙️ Logic & Safeguards
- **Manual Oversight**: Critical actions still require `/approve` if configured in OpenClaw.
- **Diagnostic Step**: The agent is forced to perform an analysis via `bridge.py` before any recovery action.

## 🚀 Installation
1. `pip install psutil`
2. Ensure `docker`, `pm2`, and `opencode` are installed.


Security scan verdicts — ClawScan: suspicious | static analysis:  | VirusTotal: clean | SkillSpector: suspicious (MEDIUM)