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/compact/freeze.py
View on GitHub"""Evals are frozen before compaction so no-skill, full and compact runs are graded on one set."""
import argparse
import json
import shutil
import sys
from pathlib import Path
from typing import Any
from anything_to_skill.compact import layout
from anything_to_skill.core.workspace import Workspace
from anything_to_skill.emit.verify import _skill_dir, process_assertions
def add_args(parser: argparse.ArgumentParser) -> None:
parser.add_argument(
'--force',
action='store_true',
help='replace the frozen set, after strengthening the evals of the full skill',
)
def cases(raw: str) -> list[dict[str, Any]]:
"""The eval cases of an evals.json text; ValueError when it is not one."""
try:
items = json.loads(raw)['evals']
except (ValueError, KeyError, TypeError) as exc:
raise ValueError('not a valid evals file: expected {"evals": [...]}') from exc
if not isinstance(items, list) or not all(isinstance(c, dict) for c in items):
raise ValueError('not a valid evals file: "evals" must be a list of objects')
return items
def load(ws: Workspace) -> str | None:
try:
return ws.evals_frozen_path.read_text('utf-8')
except OSError:
return None
def sync(ws: Workspace, source: Path, *, force: bool = False) -> str | None:
"""Freeze `source`'s evals.json (once, or again with `force`) and copy it verbatim into compact/.
Also writes eval-prompts.json (ids and prompts only): eval executors read that, never the assertions.
Returns the frozen text, or None when there is nothing to freeze.
"""
src = source / 'evals' / 'evals.json'
if (force or load(ws) is None) and src.is_file():
text = src.read_text('utf-8')
cases(text)
ws.evals_frozen_path.write_text(text, 'utf-8')
frozen = load(ws)
if frozen is None:
return None
prompts = [{'id': c.get('id'), 'prompt': c.get('prompt')} for c in cases(frozen)]
ws.eval_prompts_path.write_text(json.dumps({'evals': prompts}, indent=2), 'utf-8')
dest = ws.compact_dir / 'evals'
dest.mkdir(parents=True, exist_ok=True)
(dest / 'evals.json').write_text(frozen, 'utf-8')
trigger = source / 'evals' / 'trigger-eval.json'
if trigger.is_file() and not (dest / 'trigger-eval.json').exists():
shutil.copyfile(trigger, dest / 'trigger-eval.json')
return frozen
def run(ws: Workspace, args: argparse.Namespace) -> int:
"""`a2s.py evals-freeze`: freeze the emitted skill's evals for the compaction gate."""
source = layout.original_dir(ws, _skill_dir(ws, None))
src = source / 'evals' / 'evals.json'
old = load(ws)
if (
not args.force
and old is not None
and src.is_file()
and src.read_text('utf-8') != old
):
print(
'evals-freeze: kept the existing frozen set; the emitted evals differ '
'(pass --force to replace it)',
file=sys.stderr,
)
try:
frozen = sync(ws, source, force=args.force)
except ValueError as exc:
print(f'evals-freeze: {src}: {exc}', file=sys.stderr)
return 2
if frozen is None:
print(f'evals-freeze: no evals/evals.json under {source}', file=sys.stderr)
return 2
for f in process_assertions(frozen, 'warn'):
print(f'WARN {f.message}', file=sys.stderr)
print(
f'{ws.evals_frozen_path}: {len(cases(frozen))} evals frozen, '
f'copied to {ws.compact_dir / "evals" / "evals.json"}; '
f'executor prompts (no assertions): {ws.eval_prompts_path}'
)
return 0
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 |