CtrlK
BlogDocsLog inGet started
Tessl Logo

jbaruch/speaker-toolkit

Seven-skill presentation system: ingest talks into a rhetoric vault, run interactive clarification, generate a speaker profile, create presentations that match your documented patterns, produce the deck illustrations + thumbnail visual layer, create and publish talk-content Agent Skills with talk pages to a Jekyll shownotes site, and verify a recorded screencast against its storyboard. Includes a 113-entry Presentation Patterns taxonomy (83 observable: 64 patterns + 19 antipatterns; 30 unobservable: 21 patterns + 9 antipatterns) for scoring, brainstorming, and go-live preparation.

75

Quality

94%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide

SecuritybySnyk

Passed

No findings from the security scan

Overview
Quality
Evals
Security
Files

catalog_io.pyskills/vault-ingress/scripts/

"""Shared YAML and fingerprint primitives for Presentation Pattern catalogs."""

from __future__ import annotations

import hashlib
from collections.abc import Collection, Iterable
from pathlib import Path
from typing import Any

import yaml
from yaml.constructor import ConstructorError
from yaml.nodes import MappingNode


EvidenceSourceGroups = tuple[frozenset[str], ...]
SOURCE_COMPARISON = "source_comparison"


class DuplicateYAMLKeyError(ConstructorError):
    """A YAML mapping repeats a key that would otherwise be overwritten."""


class _DuplicateKeySafeLoader(yaml.SafeLoader):
    """SafeLoader variant that rejects duplicate keys at every nesting level."""

    def construct_mapping(
        self,
        node: MappingNode,
        deep: bool = False,
    ) -> dict[Any, Any]:
        self.flatten_mapping(node)
        mapping: dict[Any, Any] = {}
        for key_node, value_node in node.value:
            key = self.construct_object(key_node, deep=deep)
            try:
                duplicate = key in mapping
            except TypeError as exc:
                raise ConstructorError(
                    "while constructing a mapping",
                    node.start_mark,
                    f"found an unhashable mapping key {key!r}",
                    key_node.start_mark,
                ) from exc
            if duplicate:
                raise DuplicateYAMLKeyError(
                    "while constructing a mapping",
                    node.start_mark,
                    f"found duplicate mapping key {key!r}",
                    key_node.start_mark,
                )
            mapping[key] = self.construct_object(value_node, deep=deep)
        return mapping


def load_catalog_yaml(document: str) -> Any:
    """Safely load one YAML document without accepting duplicate mapping keys."""
    loader = _DuplicateKeySafeLoader(document)
    try:
        return loader.get_single_data()
    finally:
        loader.dispose()


def catalog_entry_paths(root: Path) -> list[Path]:
    """Return every recursive Markdown entry except the catalog-root index."""
    root_index = root / "_index.md"
    return sorted(
        (path for path in root.rglob("*.md") if path.is_file() and path != root_index),
        key=lambda path: path.relative_to(root).as_posix(),
    )


def parse_evidence_source_groups(
    value: object,
    allowed_sources: Collection[str],
    *,
    field_name: str = "evaluable_from",
) -> EvidenceSourceGroups:
    """Parse OR alternatives whose nested lists express conjunctive sources."""
    if not isinstance(value, list) or not value:
        raise ValueError(f"{field_name} must be a non-empty list")

    allowed = frozenset(allowed_sources)
    groups: list[frozenset[str]] = []
    for index, option in enumerate(value):
        if isinstance(option, str):
            raw_group = [option]
        elif isinstance(option, list) and len(option) >= 2:
            raw_group = option
        else:
            raise ValueError(
                f"{field_name}[{index}] must be a source string or an "
                "all-of list containing at least two sources"
            )
        if any(not isinstance(source, str) for source in raw_group):
            raise ValueError(f"{field_name}[{index}] sources must all be strings")
        if len(raw_group) != len(set(raw_group)):
            raise ValueError(f"{field_name}[{index}] contains duplicate sources")
        unknown = sorted(set(raw_group) - allowed)
        if unknown:
            raise ValueError(
                f"{field_name}[{index}] contains unknown sources: {unknown}"
            )
        group = frozenset(raw_group)
        if group == frozenset({SOURCE_COMPARISON}):
            raise ValueError(
                f"{field_name}[{index}] cannot use source_comparison as a "
                "singleton; name the exact underlying source pair"
            )
        if len(group) > 1 and SOURCE_COMPARISON in group:
            raise ValueError(
                "source_comparison labels a completed comparison and cannot be "
                "an underlying source in an all-of alternative"
            )
        if group in groups:
            raise ValueError(
                f"{field_name} contains duplicate alternative {sorted(group)}"
            )
        groups.append(group)
    return tuple(groups)


def qualifying_evidence_groups(
    groups: EvidenceSourceGroups,
    available_sources: Collection[str],
) -> tuple[frozenset[str], ...]:
    """Return alternatives satisfied by inspected sources and comparison proof."""
    available = frozenset(available_sources)
    return tuple(
        group
        for group in groups
        if group <= available and (len(group) == 1 or SOURCE_COMPARISON in available)
    )


def evidence_source_satisfies_gate(
    groups: EvidenceSourceGroups,
    evidence_source: str,
    available_sources: Collection[str],
) -> bool:
    """Return whether one detection label cites a satisfied gate alternative."""
    qualifying = qualifying_evidence_groups(groups, available_sources)
    if evidence_source == SOURCE_COMPARISON:
        return any(
            len(group) > 1 or group == frozenset({SOURCE_COMPARISON})
            for group in qualifying
        )
    return frozenset({evidence_source}) in qualifying


def catalog_fingerprint(
    index_content: bytes,
    entry_contents: Iterable[tuple[str, bytes]],
) -> str:
    """Hash the root index and recursively discovered entries deterministically."""
    digest = hashlib.sha256()

    def update(relative_path: str, content: bytes) -> None:
        digest.update(relative_path.encode("utf-8"))
        digest.update(b"\0")
        digest.update(content)
        digest.update(b"\0")

    update("_index.md", index_content)
    for relative_path, content in sorted(entry_contents):
        if relative_path == "_index.md":
            raise ValueError("root _index.md must be supplied as index_content")
        update(relative_path, content)
    return digest.hexdigest()

skills

vault-ingress

scripts

adherence_baseline.py

aggregate-catalog-feedback.py

apply-source-repairs.py

artifact_locator.py

artifact_metadata.py

artifact_supervisor.py

audit-pattern-catalog.py

audit-persisted-pattern-observations.py

audit-source-identities.py

batch-download-videos.py

build-contact-sheet.py

build-crop-reviewer.py

build-score-basis.py

catalog_dimension_registry.py

catalog_io.py

catalog_normalization.py

check-runtime.py

classify-pptx-evidence.py

cloud_artifacts.py

cooperative_lock.py

crop_frames.py

crop-reviewer-shell.html

crop-reviewer-shell.html.txt

crop-reviewer.js

crop-reviewer.js.txt

establish-date-provenance.py

failure_diagnostics.py

fetch-transcript.py

ingress_contract.py

local_media_contract.py

local_media_download.py

local_media_evidence.py

local_media_process.py

local_media_sampling.py

local_media_transcription.py

local_media_words.py

markdown_deck.py

migrate-tracking-database.py

mutate-tracking-database.py

pattern_evidence.py

pdf_evidence.py

persist-results.py

persisted_pattern_observations.py

pptx_catalog_selection.py

pptx_deck_facts.py

pptx_discovery_contract.py

pptx_evidence.py

pptx_talk_identity.py

pptx-extraction.py

preflight-vault.py

queue_claim_contract.py

queue-state.py

read-tracking-database.py

render-markdown-deck.py

render-vault-status.py

retained_stage.py

return_validation.py

run-obligations.py

scan-shownotes.py

source_alias_contract.py

source_identity_matching.py

summary_lock.py

sweep-pptx-talk-identity.py

tracking_database_io.py

tracking_database.py

transcript_quality.py

transcript_timing.py

validate-returns.py

vault_root_authority.py

video_evidence.py

video_integrity.py

video-slide-extraction.py

vtt-cleanup.py

write-analysis.py

ytdlp_runtime.py

SKILL.md

README.md

tile.json