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/core/workspace.py
View on GitHubimport json
import re
import sys
from dataclasses import dataclass
from pathlib import Path
from anything_to_skill.core.models import EFFORT_BUDGET
from anything_to_skill.core.store import Store
_SLUG = re.compile(r'^[a-z0-9][a-z0-9._-]*$')
class WorkspaceError(Exception):
pass
@dataclass(frozen=True)
class Workspace:
"""A skill build's working directory: .cc-arsenal/a2s/<slug>/ under the project."""
dir: Path
@property
def slug(self) -> str:
return self.dir.name
@property
def plan_path(self) -> Path:
return self.dir / 'plan.json'
@property
def judge_path(self) -> Path:
return self.dir / 'judge.json'
@property
def review_path(self) -> Path:
return self.dir / 'review.md'
@property
def verify_path(self) -> Path:
return self.dir / 'verify.json'
@property
def authored_dir(self) -> Path:
return self.dir / 'authored'
@property
def compact_dir(self) -> Path:
return self.dir / 'compact'
@property
def full_dir(self) -> Path:
return self.dir / 'full'
@property
def compact_brief_path(self) -> Path:
return self.dir / 'compact-brief.md'
@property
def compact_verify_path(self) -> Path:
return self.dir / 'compact-verify.json'
@property
def compact_gate_path(self) -> Path:
return self.dir / 'compact-gate.json'
@property
def eval_prompts_path(self) -> Path:
return self.dir / 'eval-prompts.json'
@property
def evals_frozen_path(self) -> Path:
return self.dir / 'evals.frozen.json'
@staticmethod
def base_dir(base: Path | None = None) -> Path:
return Path(base) if base else Path.cwd() / '.cc-arsenal' / 'a2s'
@classmethod
def create(cls, slug: str, base: Path | None = None) -> 'Workspace':
if not _SLUG.match(slug):
raise WorkspaceError(
f'invalid slug {slug!r}: use lowercase letters, digits, . _ -'
)
ws = cls(cls.base_dir(base) / slug)
ws.authored_dir.mkdir(parents=True, exist_ok=True)
(ws.dir / 'md').mkdir(exist_ok=True)
return ws
@classmethod
def find(cls, slug: str | None = None, base: Path | None = None) -> 'Workspace':
root = cls.base_dir(base)
if slug:
if not _SLUG.match(slug) or not (root / slug / 'state.db').exists():
raise WorkspaceError(
f'no workspace {slug!r} under {root}; run init first'
)
return cls(root / slug)
found = sorted(p.parent for p in root.glob('*/state.db'))
if len(found) != 1:
raise WorkspaceError(
f'{len(found)} workspaces under {root}; pass --slug'
if found
else f'no workspace under {root}; run init first'
)
return cls(found[0])
def open_store(self) -> Store:
return Store(self.dir)
@dataclass
class Ctx:
"""Everything a source's run(ctx, args) needs; goal/effort come from `a2s.py init`."""
ws: Workspace
store: Store
goal: str = ''
effort: str = 'standard'
max_pages: int | None = None
allow_private: bool = False
@classmethod
def open(
cls,
ws: Workspace,
store: Store,
max_pages: int | None = None,
*,
allow_private: bool = False,
) -> 'Ctx':
return cls(
ws=ws,
store=store,
goal=store.get_meta('goal', ''),
effort=store.get_meta('effort', 'standard'),
max_pages=max_pages,
allow_private=allow_private,
)
@property
def token_budget(self) -> int | None:
return EFFORT_BUDGET.get(self.effort)
def dropped_ids(self) -> set[int]:
"""Units the plan will not keep: `a2s drop` and judge.json's drops, which plan honors at
every effort but `complete` (no budget there) and annotate-only."""
ids = self.store.user_drops()
try:
judge = json.loads(self.ws.judge_path.read_text('utf-8'))
except (OSError, ValueError):
return ids
if isinstance(judge, dict) and not judge.get('annotate_only'):
ids |= {int(d['id']) for d in judge.get('drop', [])}
return ids
def spent_tokens(self) -> int:
"""Corpus tokens that count against the budget: dropped pages were fetched but the plan
never keeps them, so they must not stop a crawl before the wanted pages arrive."""
return self.store.token_total(exclude=self.dropped_ids())
def over_budget(self) -> bool:
budget = self.token_budget
return budget is not None and self.spent_tokens() >= budget
def log(self, message: str) -> None:
print(message, file=sys.stderr)
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 |