mgiovani/ai-arsenal / skills/anything-to-skill
anything-to-skill
VerifiedTurns 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).
scripts/anything_to_skill/sources/web/browser.py
View on GitHubimport json
import re
import shutil
import subprocess
import uuid
from urllib.parse import urlsplit
from curl_cffi.requests.impersonate import DEFAULT_CHROME
from anything_to_skill.sources.web.extract import is_blocked
BIN = 'agent-browser'
MIN_CHARS = 200
STEP_TIMEOUT_S = 60
VIEWPORT = ('1440', '900')
STEALTH_ARGS = '--disable-blink-features=AutomationControlled'
FALLBACK_CHROME_MAJOR = '150'
class BrowserBlockedError(Exception):
"""The rendered page is a challenge/denial page, not content."""
def chrome_major() -> str:
"""Chrome major that curl_cffi impersonates, so the browser and the fetcher present one identity."""
m = re.search(r'\d+', str(DEFAULT_CHROME))
return m.group() if m else FALLBACK_CHROME_MAJOR
def user_agent() -> str:
return (
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 '
f'(KHTML, like Gecko) Chrome/{chrome_major()}.0.0.0 Safari/537.36'
)
def _run(args: list[str]) -> str | None:
try:
done = subprocess.run(
[BIN, *args],
capture_output=True,
text=True,
timeout=STEP_TIMEOUT_S,
check=False,
)
except (subprocess.TimeoutExpired, OSError):
return None
return done.stdout if done.returncode == 0 else None
def _usable(text: str | None) -> str | None:
"""Text worth keeping; raises BrowserBlockedError on a challenge page."""
if not text:
return None
if is_blocked(text):
raise BrowserBlockedError
text = text.strip()
return text if len(text) >= MIN_CHARS else None
def _same_host(final: str, host: str) -> bool:
return urlsplit(final).hostname == host
def _quick(url: str, host: str, pin: str) -> tuple[str, str] | None:
"""`agent-browser read <url>`: no browser launched; enough for many JS-heavy pages."""
out = _run(['--allowed-domains', pin, 'read', url, '--json'])
try:
data = json.loads(out or '')['data']
final, content = data['finalUrl'], data['content']
except (ValueError, KeyError, TypeError):
return None
try:
text = _usable(content)
except BrowserBlockedError:
return None
return (text, final) if text and _same_host(final, host) else None
def _browse(url: str, host: str, pin: str, *, headed: bool) -> tuple[str, str] | None:
session = ['--session', f'a2s-{uuid.uuid4().hex[:8]}']
launch = [
*session,
'--allowed-domains',
pin,
'--user-agent',
user_agent(),
'--args',
STEALTH_ARGS,
]
if headed:
launch.append('--headed')
try:
if _run([*launch, 'open', url]) is None:
return None
_run([*session, 'set', 'viewport', *VIEWPORT])
_run([*session, 'wait', '--load', 'networkidle'])
final = (_run([*session, 'get', 'url']) or '').strip()
# a client-side redirect off the fetched host is never trusted, whatever it rendered
if not _same_host(final, host):
return None
text = _usable(_run([*session, 'read']))
return (text, final) if text else None
finally:
_run([*session, 'close'])
def render(url: str) -> tuple[str, str] | None:
"""(text, final URL) of a JavaScript-rendered page via agent-browser, else None.
Tries a quick `read <url>`, then a headless browser, then (only if that was blocked) a
headed retry. Every step is pinned to the page's own host with --allowed-domains, so
redirects and subresources elsewhere are refused. Raises BrowserBlockedError when the
page is still a bot challenge after the retry; a challenge is never solved.
--profile is deliberately absent: agent-browser refuses --allowed-domains together
with --profile (and with --user-data-dir), and the host pin is not negotiable.
"""
host = urlsplit(url).hostname
if not host or not shutil.which(BIN):
return None
pin = f'{host},*.{host}'
if found := _quick(url, host, pin):
return found
try:
return _browse(url, host, pin, headed=False)
except BrowserBlockedError:
found = _browse(url, host, pin, headed=True)
if found is None:
raise
return found
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| 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: 198k | Updated | Claude CodeCodex | Verified | Install |
| 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: 198k | Updated | Claude CodeCodex | Verified | Install |
| 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: 198k | Updated | Claude CodeCodex | Verified | Install |
| 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: 198k | Updated | Claude CodeCodex | Verified | Install |