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_config.py

View on GitHub
"""Resolves the LLM-assist level (none/slight/lot).

Precedence: --assist flag > CONTEXT_GARDEN_LLM_ASSIST env var >
`llm_assist.level` in the nearest .context-garden/config.yaml walking up >
"none". See references/llm-assist.md.
"""

from __future__ import annotations

import os
from pathlib import Path

LEVELS = ("none", "slight", "lot")
DEFAULT_LEVEL = "none"
ENV_VAR = "CONTEXT_GARDEN_LLM_ASSIST"
CONFIG_RELPATH = Path(".context-garden") / "config.yaml"


def _parse_minimal_yaml(text: str) -> dict:
    """Only flat `key: value` lines plus one level of indented nesting; not a
    general YAML parser, to avoid a PyYAML dependency."""
    root: dict = {}
    stack: list[tuple[int, dict]] = [(-1, root)]
    for raw_line in text.splitlines():
        line = raw_line.split("#", 1)[0].rstrip()
        if not line.strip():
            continue
        indent = len(line) - len(line.lstrip(" "))
        key, sep, value = line.strip().partition(":")
        if not sep:
            continue
        value = value.strip()
        while len(stack) > 1 and indent <= stack[-1][0]:
            stack.pop()
        parent = stack[-1][1]
        if value:
            parent[key] = value
        else:
            child: dict = {}
            parent[key] = child
            stack.append((indent, child))
    return root


def find_config_file(start_dir) -> Path | None:
    d = Path(start_dir).resolve()
    for candidate in (d, *d.parents):
        p = candidate / CONFIG_RELPATH
        if p.is_file():
            return p
    return None


def resolve_assist_level(explicit: str | None = None, start_dir=None) -> str:
    if explicit:
        if explicit not in LEVELS:
            raise ValueError(f"invalid assist level {explicit!r}, expected one of {LEVELS}")
        return explicit

    env_value = os.environ.get(ENV_VAR)
    if env_value:
        if env_value not in LEVELS:
            raise ValueError(f"invalid {ENV_VAR}={env_value!r}, expected one of {LEVELS}")
        return env_value

    config_path = find_config_file(start_dir if start_dir is not None else Path.cwd())
    if config_path is not None:
        config = _parse_minimal_yaml(config_path.read_text())
        assist = config.get("llm_assist", {})
        level = assist.get("level") if isinstance(assist, dict) else None
        if level:
            if level not in LEVELS:
                raise ValueError(
                    f"invalid llm_assist.level={level!r} in {config_path}, expected one of {LEVELS}"
                )
            return level

    return DEFAULT_LEVEL
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