Skip to content

mgiovani/ai-arsenal / skills/anything-to-skill

anything-to-skill

Verified

Turns a docs site, local folder, PDF or book, YouTube video, playlist or channel, or a topic into a source-grounded, token-efficient agent skill (hub SKILL.md, sectioned references, INDEX, evals), and can compact it into a lean expert skill. Use for "make a skill from these docs", "turn this channel into a skill". Not for a skill from your own description (use create-skill), improving one (use improve-skill) or finding third-party skills (use find-skills).

FileKindSize
SKILL.mdskill md29.0 KB
assets/templates/SKILL.md.tmplother53 B
assets/templates/evals.json.tmplother41 B
assets/templates/trigger-eval.json.tmplother9 B
evals/evals.jsonconfig6.2 KB
evals/trigger-eval.jsonconfig1.9 KB
references/compaction.mdmarkdown5.8 KB
references/evals.mdmarkdown2.9 KB
references/extending.mdmarkdown2.6 KB
references/generated-skill-layout.mdmarkdown7.1 KB
references/interview.mdmarkdown2.7 KB
references/judge.mdmarkdown3.5 KB
references/sources.mdmarkdown11.1 KB
scripts/a2s.pyexecutablescript520 B
scripts/anything_to_skill/__init__.pyscript0 B
scripts/anything_to_skill/cli.pyscript17.5 KB
scripts/anything_to_skill/compact/__init__.pyscript0 B
scripts/anything_to_skill/compact/brief.pyscript8.2 KB
scripts/anything_to_skill/compact/freeze.pyscript3.5 KB
scripts/anything_to_skill/compact/gate.pyscript2.8 KB
scripts/anything_to_skill/compact/layout.pyscript1.6 KB
scripts/anything_to_skill/compact/swap.pyscript3.8 KB
scripts/anything_to_skill/compact/verify.pyscript15.4 KB
scripts/anything_to_skill/core/__init__.pyscript0 B
scripts/anything_to_skill/core/models.pyscript3.1 KB
scripts/anything_to_skill/core/sanitize.pyscript2.1 KB
scripts/anything_to_skill/core/ssrf.pyscript1.8 KB
scripts/anything_to_skill/core/store.pyscript13.8 KB
scripts/anything_to_skill/core/tokens.pyscript147 B
scripts/anything_to_skill/core/workspace.pyscript4.7 KB
scripts/anything_to_skill/emit/__init__.pyscript0 B
scripts/anything_to_skill/emit/link.pyscript612 B
scripts/anything_to_skill/emit/templates.pyscript398 B
scripts/anything_to_skill/emit/verify.pyscript9.7 KB
scripts/anything_to_skill/emit/write.pyscript21.0 KB
scripts/anything_to_skill/laya/__init__.pyscript0 B
scripts/anything_to_skill/laya/apply.pyscript3.1 KB
scripts/anything_to_skill/laya/brain.pyscript6.9 KB
scripts/anything_to_skill/laya/client.pyscript2.2 KB
scripts/anything_to_skill/laya/factcheck.pyscript10.5 KB
scripts/anything_to_skill/laya/judge.pyscript6.8 KB
scripts/anything_to_skill/laya/questions.pyscript2.1 KB
scripts/anything_to_skill/plan/__init__.pyscript0 B
scripts/anything_to_skill/plan/brief.pyscript8.1 KB
scripts/anything_to_skill/plan/index.pyscript912 B
scripts/anything_to_skill/plan/pack.pyscript16.6 KB
scripts/anything_to_skill/plan/priority.pyscript5.0 KB
scripts/anything_to_skill/plan/tree.pyscript19.1 KB
scripts/anything_to_skill/scan/__init__.pyscript0 B
scripts/anything_to_skill/scan/credentials.pyscript1.1 KB
scripts/anything_to_skill/scan/injection.pyscript1.9 KB
scripts/anything_to_skill/scan/quotes.pyscript8.4 KB
scripts/anything_to_skill/scan/unicode.pyscript691 B
scripts/anything_to_skill/sources/__init__.pyscript1.2 KB
scripts/anything_to_skill/sources/local/__init__.pyscript0 B
scripts/anything_to_skill/sources/local/convert.pyscript4.6 KB
scripts/anything_to_skill/sources/local/detect.pyscript178 B
scripts/anything_to_skill/sources/local/run.pyscript4.5 KB
scripts/anything_to_skill/sources/local/walk.pyscript1.1 KB
scripts/anything_to_skill/sources/web/__init__.pyscript0 B
scripts/anything_to_skill/sources/web/browser.pyscript4.2 KB
scripts/anything_to_skill/sources/web/detect.pyscript144 B
scripts/anything_to_skill/sources/web/discover.pyscript21.4 KB
scripts/anything_to_skill/sources/web/extract.pyscript13.0 KB
scripts/anything_to_skill/sources/web/fetch.pyscript8.7 KB
scripts/anything_to_skill/sources/web/frontier.pyscript9.5 KB
scripts/anything_to_skill/sources/web/run.pyscript12.6 KB
scripts/anything_to_skill/sources/web/throttle.pyscript7.3 KB
scripts/anything_to_skill/sources/youtube/__init__.pyscript0 B
scripts/anything_to_skill/sources/youtube/asr.pyscript1.5 KB
scripts/anything_to_skill/sources/youtube/captions.pyscript2.4 KB
scripts/anything_to_skill/sources/youtube/detect.pyscript313 B
scripts/anything_to_skill/sources/youtube/frames.pyscript3.8 KB
scripts/anything_to_skill/sources/youtube/funnel.pyscript7.4 KB
scripts/anything_to_skill/sources/youtube/listing.pyscript5.8 KB
scripts/anything_to_skill/sources/youtube/run.pyscript21.5 KB
scripts/anything_to_skill/sources/youtube/vtt.pyscript3.3 KB
scripts/convert_docling.pyexecutablescript513 B
scripts/crawl_brain.pyexecutablescript637 B
scripts/ingest_local.pyexecutablescript463 B
scripts/ingest_web.pyexecutablescript593 B
scripts/ingest_youtube.pyexecutablescript533 B
scripts/judge.pyexecutablescript481 B
scripts/transcribe.pyexecutablescript689 B
scripts/verify_laya.pyexecutablescript925 B
scripts/youtube_brain.pyexecutablescript598 B

scripts/anything_to_skill/sources/web/frontier.py

View on GitHub
import importlib
import math
import re
from collections.abc import Callable
from dataclasses import dataclass
from html.parser import HTMLParser
from typing import Protocol
from urllib.parse import urldefrag, urljoin, urlsplit

MIN_STEM = 3
MIN_PREFIX = 4  # shortest word allowed to match by prefix (link "vacuum" vs "vacuumdb")
PRIORITY_SCALE = 10.0
MIN_IDF_DOCS = 20  # below this many candidates, document frequencies say nothing
_WORD = re.compile(r'[a-z0-9]{3,}')
_STOP = frozenset(
    [
        'the',
        'and',
        'for',
        'with',
        'best',
        'practice',
        'practices',
        'how',
        'use',
        'using',
        'guide',
        'about',
        'from',
        'that',
        'this',
        'what',
        'your',
        'into',
        'are',
        'can',
        'you',
        'not',
        'all',
        'any',
        'get',
        'set',
    ]
)
_NON_DOC_EXT = frozenset(
    [
        '.png',
        '.jpg',
        '.jpeg',
        '.gif',
        '.svg',
        '.webp',
        '.ico',
        '.css',
        '.js',
        '.json',
        '.xml',
        '.zip',
        '.gz',
        '.tar',
        '.tgz',
        '.pdf',
        '.mp4',
        '.mp3',
        '.woff',
        '.woff2',
        '.ttf',
        '.eot',
        '.map',
    ]
)
_DOC_EXT = frozenset(['', '.html', '.htm', '.md', '.txt', '.php', '.aspx'])
# Site chrome: never the knowledge a skill wants, so it is fetched after the content.
_CHROME = re.compile(
    r'^(?:contact(?:-us)?|legal|imprint|impressum|privacy(?:-policy)?|terms(?:-[a-z-]+)?|'
    r'shop|store|cart|checkout|about(?:-us)?|login|log-in|signin|sign-in|signup|sign-up|'
    r'register|account|tags?|authors?)(?:\.\w+)?$'
)
CHROME_PENALTY = 0.4


@dataclass
class Link:
    url: str
    anchor: str = ''
    heading: str = ''


class LinkScorer(Protocol):
    def score(
        self, goal: str, page_title: str, heading_path: str, candidates: list[Link]
    ) -> list[float]:
        """One probability-like score per candidate, same order; only affects fetch order."""
        ...


def keywords(goal: str) -> list[str]:
    return sorted({w for w in _WORD.findall(goal.lower()) if w not in _STOP})


def _stems(goal: str) -> list[str]:
    return sorted({_stem(k) for k in keywords(goal)})


def _ext(path: str) -> str:
    leaf = path.rsplit('/', 1)[-1]
    return '.' + leaf.rsplit('.', 1)[-1].lower() if '.' in leaf else ''


def _stem(word: str) -> str:
    """Strip a plural/participle suffix so 'indexing', 'indexes' and 'index' meet."""
    for suffix, tail in (('ies', 'y'), ('ing', ''), ('es', ''), ('ed', ''), ('s', '')):
        if word.endswith(suffix) and len(word) - len(suffix) >= MIN_STEM:
            return word[: -len(suffix)] + tail
    return word


def _matches(keyword: str, words: set[str]) -> bool:
    """Word match on stems: 'indexing' hits 'indexes', 'sql' does not hit 'mysql'."""
    return any(
        w.startswith(keyword) or (len(w) >= MIN_PREFIX and keyword.startswith(w))
        for w in words
    )


def _weights(kws: list[str], docs: list[set[str]]) -> dict[str, float]:
    """BM25 idf of each keyword over the candidates: 'sql' in most URLs of a SQL docs site
    weighs almost nothing, 'performance' in a few weighs a lot. Keywords no candidate contains
    are left out, so they cannot dilute the ones that can discriminate."""
    n = len(docs)
    if n < MIN_IDF_DOCS:
        return dict.fromkeys(kws, 1.0)
    out = {}
    for k in kws:
        if df := sum(_matches(k, words) for words in docs):
            out[k] = math.log(1 + (n - df + 0.5) / (df + 0.5))
    return out


def is_doc_url(url: str) -> bool:
    return _ext(urlsplit(url).path) not in _NON_DOC_EXT


class RulesScorer:
    """Cheap deterministic ranking: goal keywords, scope prefix, path depth, content type."""

    def __init__(self, goal: str, scope: str | None = None) -> None:
        self.goal = goal
        self.scope = scope or '/'
        self._kw = _stems(goal)

    def hits(self, goal: str, candidates: list[Link]) -> list[float]:
        """Share (0..1) of the goal's terms in each candidate's anchor, path and heading,
        weighted by how rare each term is among these candidates."""
        kws = _stems(goal) if goal and goal != self.goal else self._kw
        words = [
            {
                _stem(w)
                for w in _WORD.findall(
                    f'{c.anchor} {urlsplit(c.url).path} {c.heading}'.lower()
                )
            }
            for c in candidates
        ]
        weights = _weights(kws, words)
        total = sum(weights.values())
        if not total:
            return [0.0] * len(candidates)
        return [
            sum(w for k, w in weights.items() if _matches(k, found)) / total
            for found in words
        ]

    def score(
        self,
        goal: str,
        page_title: str,  # noqa: ARG002 - context for model-backed scorers; rules ignore it
        heading_path: str,  # noqa: ARG002
        candidates: list[Link],
    ) -> list[float]:
        base = self.scope.strip('/').count('/') + 1 if self.scope.strip('/') else 0
        out = []
        for c, hit in zip(candidates, self.hits(goal, candidates), strict=True):
            path = urlsplit(c.url).path
            ext = _ext(path)
            if ext in _NON_DOC_EXT:
                out.append(0.0)
                continue
            extra = (
                max(0, path.strip('/').count('/') + 1 - base) if path.strip('/') else 0
            )
            in_scope = path.startswith(self.scope)
            chrome = hit == 0 and any(
                _CHROME.match(seg) for seg in path.lower().strip('/').split('/')
            )
            score = (
                0.5 * hit
                + 0.2 * in_scope
                + 0.2 / (1 + extra)
                + (0.1 if ext in _DOC_EXT else 0.0)
                - (CHROME_PENALTY if chrome else 0.0)
            )
            out.append(round(max(0.0, min(1.0, score)), 4))
        return out


class GuardedScorer:
    """Runs a model-backed scorer but degrades to rules on any error: order-only, so benign."""

    def __init__(
        self, primary: LinkScorer, fallback: LinkScorer, log: Callable[[str], None]
    ) -> None:
        self.primary = primary
        self.fallback = fallback
        self.log = log
        self.failed = False

    def score(
        self, goal: str, page_title: str, heading_path: str, candidates: list[Link]
    ) -> list[float]:
        if not self.failed:
            try:
                scores = self.primary.score(goal, page_title, heading_path, candidates)
                if len(scores) == len(candidates):
                    return scores
                raise ValueError('scorer returned a wrong number of scores')
            except Exception as exc:  # noqa: BLE001 - any brain failure must not stop a crawl
                self.failed = True
                self.log(f'warning: --brain scorer failed ({exc!r}); using rules')
        return self.fallback.score(goal, page_title, heading_path, candidates)


def make_scorer(
    goal: str, brain: str, scope: str | None, log: Callable[[str], None]
) -> LinkScorer:
    """RulesScorer, or Laya wrapped in a guard; a missing Laya falls back with a warning."""
    rules = RulesScorer(goal, scope)
    if brain != 'laya':
        return rules
    try:
        laya = importlib.import_module('anything_to_skill.laya.brain')
        return GuardedScorer(laya.LayaScorer(goal), rules, log)
    except Exception as exc:  # noqa: BLE001 - laya is optional and heavy
        log(f'warning: --brain laya unavailable ({exc!r}); using rules')
        return rules


def priority(score: float) -> float:
    return round(score * PRIORITY_SCALE, 3)


class _Links(HTMLParser):
    def __init__(self, base: str) -> None:
        super().__init__()
        self.base = base
        self.links: dict[str, Link] = {}
        self._heading = ''
        self._in_heading = False
        self._href: str | None = None
        self._anchor: list[str] = []

    def handle_starttag(self, tag: str, attrs: list[tuple[str, str | None]]) -> None:
        if tag in ('h1', 'h2', 'h3'):
            self._in_heading, self._heading = True, ''
        elif tag == 'a':
            self._href = dict(attrs).get('href')
            self._anchor = []

    def handle_endtag(self, tag: str) -> None:
        if tag in ('h1', 'h2', 'h3'):
            self._in_heading = False
        elif tag == 'a' and self._href:
            try:
                url = urldefrag(urljoin(self.base, self._href))[0]
                scheme = urlsplit(url).scheme
            except ValueError:  # e.g. href="//[oops": one bad link must not fail the page
                self._href = None
                return
            anchor = ' '.join(''.join(self._anchor).split())
            known = self.links.get(url)
            # A page links the same URL as "Next" in its nav bar and by name in its
            # contents; the name is the one worth scoring.
            if scheme in ('http', 'https') and (
                known is None or len(anchor) > len(known.anchor)
            ):
                self.links[url] = Link(url, anchor, self._heading.strip())
            self._href = None

    def handle_data(self, data: str) -> None:
        if self._in_heading:
            self._heading += data
        if self._href is not None:
            self._anchor.append(data)


def extract_links(html: str, base_url: str) -> list[Link]:
    """Absolute, fragment-free links with anchor text and the nearest preceding heading."""
    parser = _Links(base_url)
    parser.feed(html)
    return list(parser.links.values())
canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill.Stars: 198kUpdated Claude CodeCodexVerifiedInstall