aboutsummaryrefslogtreecommitdiffstats
path: root/.agents/skills/skill-quality-reviewer/scripts/skill-audit.py
blob: 8f047c3c397e1bbd8f2a402db16e5cd4ac2aeb94 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python3
from __future__ import annotations

import argparse
import re
from pathlib import Path

REF_RE = re.compile(r'(references/[^\s)`]+|examples/[^\s)`]+|scripts/[^\s)`]+|assets/[^\s)`]+)')


def parse_args() -> argparse.Namespace:
    parser = argparse.ArgumentParser(description='Audit a skill for missing local references and rough size metrics.')
    parser.add_argument('skill_path', help='Path to the skill directory')
    return parser.parse_args()


def main() -> int:
    args = parse_args()
    root = Path(args.skill_path).expanduser().resolve()
    skill_md = root / 'SKILL.md'
    if not skill_md.exists():
        print('missing SKILL.md')
        return 1
    text = skill_md.read_text(encoding='utf-8')
    words = len(re.findall(r'\w+', text))
    print(f'word_count={words}')
    refs = sorted(set(match.rstrip('*:.,') for match in REF_RE.findall(text)))
    missing = [ref for ref in refs if not (root / ref).exists()]
    if missing:
        print('missing_refs=')
        for ref in missing:
            print(f'- {ref}')
    else:
        print('missing_refs=0')
    return 0


if __name__ == '__main__':
    raise SystemExit(main())