Skip to content

oliverweissl/context-garden / skills/weeder

weeder

Verified

Measure and reduce a Skill's token footprint (always-loaded description + on-trigger SKILL.md body) without regressing routing accuracy or losing instructions. Use when a SKILL.md feels oversized, repeats rules, or has a vague description that might mis-route.

scripts/we_text.py

View on GitHub
"""Shared markdown-aware text cleaning for duplicate/filler detection.

Code fences and heading/list markers have no terminal punctuation, so left in
they glue onto adjacent sentences and repeated usage examples look like
"the same rule repeated five times".
"""

from __future__ import annotations

import re

_CODE_FENCE_RE = re.compile(r"```.*?```", re.DOTALL)
_INLINE_CODE_RE = re.compile(r"`[^`\n]*`")
_HEADING_LINE_RE = re.compile(r"^\s*#{1,6}\s+.*$", re.MULTILINE)
_LIST_MARKER_RE = re.compile(r"^\s*(?:[-*]|\d+\.)\s+", re.MULTILINE)
_SENTENCE_RE = re.compile(r"(?<=[.!?])\s+")


def strip_code(text: str) -> str:
    text = _CODE_FENCE_RE.sub(" ", text)
    text = _INLINE_CODE_RE.sub(" ", text)
    return text


def strip_markdown_structure(text: str) -> str:
    """Code blocks + heading lines + leading list markers removed, safe to
    feed to a sentence splitter without structural elements gluing onto
    adjacent prose."""
    text = strip_code(text)
    text = _HEADING_LINE_RE.sub("", text)
    text = _LIST_MARKER_RE.sub("", text)
    return text


def split_into_sentences(text: str) -> list[str]:
    cleaned = strip_markdown_structure(text).replace("\n", " ")
    return [s.strip() for s in _SENTENCE_RE.split(cleaned) if s.strip()]


_BOUNDARY = "\x00"


def split_into_original_sentences(text: str) -> list[str]:
    """Like split_into_sentences, but each sentence is a verbatim span of
    `text` (inline code kept; only newlines flattened): code blocks, heading
    lines and list markers become sentence *boundaries* instead of being
    deleted mid-span. Duplicate-group members must be findable in the
    original file by apply-suggestion -- a sentence with its `inline code`
    stripped is not. Callers compute similarity on strip_code(sentence)."""
    marked = _CODE_FENCE_RE.sub(_BOUNDARY, text)
    marked = _HEADING_LINE_RE.sub(_BOUNDARY, marked)
    marked = _LIST_MARKER_RE.sub(_BOUNDARY, marked)
    out = []
    for block in marked.split(_BOUNDARY):
        out.extend(s.strip() for s in _SENTENCE_RE.split(block.replace("\n", " ")) if s.strip())
    return out
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall