#!/usr/bin/env python3 """ PPT Master - Prompt Budget Audit Tool Audits the repository's agent-facing documents without modifying them. Reports exact o200k_base token counts, declared load-set budgets, Markdown references, registry claims, schema-definition candidates, and cross-file duplication. Usage: python3 scripts/prompt_audit.py python3 scripts/prompt_audit.py --json python3 scripts/prompt_audit.py --root /path/to/ppt-master Examples: python3 skills/ppt-master/scripts/prompt_audit.py python3 skills/ppt-master/scripts/prompt_audit.py --json | python3 -m json.tool Dependencies: tiktoken (o200k_base encoding) """ from __future__ import annotations import argparse import hashlib import json import re import statistics import sys from collections import Counter, defaultdict from dataclasses import asdict, dataclass, field from difflib import SequenceMatcher from pathlib import Path, PurePosixPath from typing import Any, Iterable from urllib.parse import unquote from console_encoding import configure_utf8_stdio configure_utf8_stdio() _MARKDOWN_LINK_RE = re.compile(r"(?:+-]+|[\u3400-\u9fff]") _HEADING_RE = re.compile(r"^#{1,6}\s+") _FENCE_RE = re.compile(r"^\s*(```|~~~)") _SCHEMA_HEADING_RE = re.compile(r"^##\s+([A-Za-z][A-Za-z0-9_.-]*)\s*$") _REGISTRY_INDEX_ENTRY_RE = re.compile( r"^\|\s*\[`(?P