diff --git a/.AI-SAFEGUARDS.md b/.AI-SAFEGUARDS.md deleted file mode 100644 index f7289d84..00000000 --- a/.AI-SAFEGUARDS.md +++ /dev/null @@ -1,56 +0,0 @@ -# AI Safeguards Configuration - -## Protected Branches - -These branches CANNOT be modified by AI: - -- docs-v2 (source of truth) -- main - -## Allowed Branches for AI - -- docs-v2-dev (development branch for hourly commits) -- fix-\* (feature branches) -- safepoint/\* (checkpoint branches) - -## Forbidden Commands for AI - -❌ NEVER execute: - -- git reset --hard -- git restore . -- git clean -fd -- git push --force -- git rebase -i (interactive rebase) -- git tag --force -- Any mass git operations without human approval - -## Large Change Protocol (>10 files) - -1. AI must show file list and get approval -2. Human creates .ai-commit-verified file -3. Only then can AI proceed with commit -4. File is deleted after commit - -## Audit Trail - -All AI git operations logged to: .ai-operations.log - -## Emergency Rollback - -If AI makes dangerous changes: - -```bash -git reflog -git reset --hard -``` - -## Human Commit Override - -If AI blocks legitimate commits, use: - -```bash -git commit --no-verify -``` - -Updated: 2026-01-06 after safeguard implementation diff --git a/.ai-audit.sh b/.ai-audit.sh deleted file mode 100644 index 1911795f..00000000 --- a/.ai-audit.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -# AI Operations Audit Log -# Logs every git operation attempted by the AI assistant - -TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S') -BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "unknown") -COMMAND="$*" -FILES_CHANGED=$(git status --porcelain 2>/dev/null | wc -l) - -LOG_ENTRY="[$TIMESTAMP] BRANCH=$BRANCH | COMMAND=$COMMAND | FILES_STAGED=$FILES_CHANGED" - -# Write to audit log -echo "$LOG_ENTRY" >> .ai-operations.log - -# Also print for visibility -echo "$LOG_ENTRY" diff --git a/.augment/.augment-guidelines b/.augment/.augment-guidelines new file mode 100644 index 00000000..a7129af7 --- /dev/null +++ b/.augment/.augment-guidelines @@ -0,0 +1,17 @@ +# Standard Operating Procedure for Scripts + + + +## 1. Safety & Verification Workflow + +- Before applying changes to existing files, you MUST: + 1. Create a "checkpoint" backup using the internal checkpoint tool. + 2. Create a new git branch named `agent/[feature-name]`. + 3. Verify the script's logic by applying it to a temporary copy of the target + file first. + 4. Only after verification and user approval, apply the changes to the project + files in the new branch. diff --git a/.augment/rules/git-safety.md b/.augment/rules/git-safety.md new file mode 100644 index 00000000..3e5ce50a --- /dev/null +++ b/.augment/rules/git-safety.md @@ -0,0 +1,5 @@ +# GIT WRITE PROTOCOL +- **ENFORCEMENT:** You MUST verify the existence of local Git hooks in `.git/hooks/` before initiating any write command (commit, push, rebase). +- **FORBIDDEN:** You are STRICTLY FORBIDDEN from using `--no-verify` or `-n`. +- **BEHAVIOR:** When a write command is initiated, you MUST announce: "Initiating [action]. Please approve the safety checkpoint in your terminal." +- **RECOVERY:** If a command fails, suggest restoring from the latest `checkpoint/` branch. diff --git a/.github/AGENTS.md b/.github/AGENTS.md new file mode 100644 index 00000000..d9d49698 --- /dev/null +++ b/.github/AGENTS.md @@ -0,0 +1,39 @@ +# 🤖 PROJECT AGENT RULES & SAFETY PROTOCOLS + +## 🛠️ CRITICAL BOUNDARIES (READ FIRST) + +- **ALWAYS** check for the existence of local Git hooks in `.git/hooks/` before + initiating a write command. +- **NEVER** use `--no-verify` or `-n` flags to bypass safety checks. These are + hard project constraints. +- **NEVER** perform a `git reset --hard` or `git push --force` without an + explicit, multi-turn plan confirmed by the user. +- **NEVER** perform a `git reset --hard` or `git push --force` without a saved + branch to revert to in case of failure. + +## 📦 GIT WORKFLOW & CHECKPOINTS + +This project enforces a "Human-in-the-Loop" (HitL) verification for all +destructive or history-altering actions. + +- **Automatic Checkpoints:** Every `commit`, `push`, and `rebase` triggers a + safety hook that creates a branch named `checkpoint/YYYY-MM-DD_HHMMSS`. +- **Pre-Write Announcement:** Before executing a write command, you MUST state: + _"I am initiating [COMMAND]. A safety checkpoint will be created. Please + switch to your terminal to type 'yes' when prompted."_ +- **Recovery:** If a command fails, the latest pre-failure state is stored in + the most recent `checkpoint/` branch. + +## 🧪 VALIDATION COMMANDS + +Before asking for a commit, you should ideally run these to ensure code quality: + +```bash +# Verify build +mint dev +``` + +# Run local test suite + +Make a test for mintlify in the v2/tests file. DO NOT EVER run a script without +testing it on a local branch first. diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 7ab9f32f..569056b5 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -13,7 +13,7 @@ containerized with Docker. - Use `.tsx` for new components; `.jsx` is legacy but supported. - **Automations & Scripts:** - All dynamic, AI, and data-fetching logic in `automations/` and `ai-tools/`. - - Scripts for API doc generation and external data in `v2/scripts/` (see + - Scripts for API doc generation and external data in `snippets/scripts/` (see generate-api-docs.sh, fetch-openapi-specs.sh). - **API Reference:** - OpenAPI spec in `openapi.yaml` (AI API: see ai/worker/api/openapi.yaml). Use @@ -32,10 +32,10 @@ containerized with Docker. `docker buildx build --platform linux/amd64 --load -t livepeer/docs .` - Makefile: `make all` - **API Docs Generation:** - - Use `v2/scripts/generate-api-docs.sh` to convert OpenAPI specs to MDX/API - docs and navigation JSON. Example: + - Use `snippets/scripts/generate-api-docs.sh` to convert OpenAPI specs to + MDX/API docs and navigation JSON. Example: ```bash - ./v2/scripts/generate-api-docs.sh ai/worker/api/openapi.yaml v2/pages/04_gateways/guides-references/api-reference/AI-API "AI API" + ./snippets/scripts/generate-api-docs.sh ai/worker/api/openapi.yaml v2/pages/04_gateways/guides-references/api-reference/AI-API "AI API" ``` - Output: MDX files + navigation snippet for `docs.json`. - **External Data Fetching:** @@ -72,8 +72,8 @@ containerized with Docker. - **OpenAPI:** API docs generated from `openapi.yaml` (see also `ai/worker/api/openapi.yaml`). - **Docker:** Containerized builds for CI/CD and local dev. -- **Automations:** Scripts in `v2/scripts/` automate API doc generation and - external data sync. +- **Automations:** Scripts in `snippets/scripts/` automate API doc generation + and external data sync. ## Key Files & Directories @@ -83,7 +83,7 @@ containerized with Docker. - `openapi.yaml`, `ai/worker/api/openapi.yaml` — API reference - `Dockerfile`, `Makefile` — Build/deploy - `README.md`, `README_V2.md` — Developer notes, protocol/architecture -- `v2/scripts/` — Automation scripts (API docs, data fetching) +- `snippets/scripts/` — Automation scripts (API docs, data fetching) --- diff --git a/.github/scripts/fetch-forum-data.js b/.github/scripts/fetch-forum-data.js new file mode 100644 index 00000000..fa6f6fc8 --- /dev/null +++ b/.github/scripts/fetch-forum-data.js @@ -0,0 +1,198 @@ +const https = require("https"); +const fs = require("fs"); + +// Fetch JSON from URL +function fetchJSON(url) { + return new Promise((resolve, reject) => { + https + .get(url, (res) => { + let data = ""; + res.on("data", (chunk) => { + data += chunk; + }); + res.on("end", () => { + try { + resolve(JSON.parse(data)); + } catch (e) { + reject(e); + } + }); + }) + .on("error", reject); + }); +} + +// Check if topic is old pinned +function isOldPinned(topic) { + const pinned = topic.pinned === true || topic.pinned_globally === true; + if (!pinned) return false; + const created = new Date(topic.created_at); + const now = new Date(); + const ageDays = (now - created) / (1000 * 60 * 60 * 24); + return ageDays > 30; +} + +// Clean and format HTML +function cleanAndFormatHTML(html) { + let cleanHTML = html; + + // Remove anchor navigation links + cleanHTML = cleanHTML.replace( + /]*name="[^"]*"[^>]*class="anchor"[^>]*>.*?<\/a>/g, + "" + ); + + // Clean up headings + cleanHTML = cleanHTML.replace(/]*>(.*?)<\/h1>/g, "

$1

"); + cleanHTML = cleanHTML.replace(/]*>(.*?)<\/h2>/g, "

$1

"); + cleanHTML = cleanHTML.replace(/]*>(.*?)<\/h3>/g, "
$1
"); + cleanHTML = cleanHTML.replace(/]*>(.*?)<\/h[4-6]>/g, "
$1
"); + + // Clean up images and their references + cleanHTML = cleanHTML.replace(/]*class="lightbox"[^>]*>.*?<\/a>/g, ""); + cleanHTML = cleanHTML.replace( + /]*class="lightbox-wrapper"[^>]*>.*?<\/div>/g, + "" + ); + cleanHTML = cleanHTML.replace(/]*>/g, ""); + cleanHTML = cleanHTML.replace(/\[!\[.*?\]\(.*?\)\]\(.*?\)/g, ""); + cleanHTML = cleanHTML.replace(/image\d+×\d+\s+[\d.]+\s*[KM]B/gi, ""); + + // Keep paragraphs, lists, emphasis, code + cleanHTML = cleanHTML.replace(/

/g, "

"); + cleanHTML = cleanHTML.replace(/<\/p>/g, "

"); + cleanHTML = cleanHTML.replace(/