Skip to content

Cassiiopeia/projectops / plugins/projectops-extras/skills/pro-skill-bug

pro-skill-bug

Verified

Report a suspected projectops skill bug from this session: gather facts from the transcript, strip personal data, file an issue, return to the task. Use, even if unsure, when a pro-* tool result disagrees with reality, you loop or work around a skill, or the user asks 'is this a bug?'.

FileKindSize
SKILL.mdskill md11.5 KB
scripts/bug/__init__.pyscript89 B
scripts/bug/alarm.pyscript1.3 KB
scripts/bug/context.pyscript4.2 KB
scripts/bug/excerpt.pyscript8.7 KB
scripts/bug/redact.pyscript3.4 KB
scripts/bug/transcript.pyscript5.5 KB
scripts/bug_cli.pyscript9.5 KB

scripts/bug/excerpt.py

View on GitHub
"""Session events > issue excerpt: projectops command/result pairs, user messages after them, skills used, image paths (all redacted)"""
from __future__ import annotations

import re
from pathlib import Path

from bug.redact import redact_text

# Markers that identify a projectops command (skill CLI · stable entry point)
PROJECTOPS_COMMAND_MARKERS = ("launch_cli.py", "projectops_cli.py", "_cli.py", "/.projectops/")
IMAGE_SUFFIXES = (".png", ".jpg", ".jpeg", ".webp", ".gif")
# Left boundary: excludes URL fragments (//host/…) and paths mid-word
IMAGE_PATH_RE = re.compile(r"(?<![\w/:.])(~?/[^\s\"'<>|;]+?\.(?:png|jpe?g|webp|gif))\b", re.IGNORECASE)
# Commands whose output is dropped entirely (projectops config = PAT · server passwords)
OMITTED_COMMAND_MARKERS = (".projectops/config",)
OMITTED_RESULT = "<omitted: projectops config file>"
# Number of user reactions appended after the --around window
USER_REACTIONS_AFTER_WINDOW = 3
# Anchor call window: anchor raw output limit, flow output limit, agent text limit, number of earlier state commands (#1000)
ANCHOR_RESULT_MAX_CHARS = 20000
FLOW_RESULT_MAX_CHARS = 2000
AGENT_NOTE_MAX_CHARS = 500
SETUP_COMMANDS_KEPT = 10


def is_projectops_command(text: str) -> bool:
    return any(marker in text for marker in PROJECTOPS_COMMAND_MARKERS)


def _clip(text: str, max_chars: int) -> tuple[str, bool, dict]:
    """Redact > truncate to the character limit > (text, truncated, redaction count)"""
    redacted, counts = redact_text(text or "")
    return redacted[:max_chars], len(redacted) > max_chars, counts


def _merge_counts(total: dict, counts: dict) -> None:
    for kind, hits in counts.items():
        total[kind] = total.get(kind, 0) + hits


def _image_paths(events: list[dict], start_index: int) -> list[dict]:
    """Image paths in commands and results that exist as files (capture paths appear in result JSON)"""
    seen, images = set(), []
    for event in events:
        if event["kind"] not in ("tool_use", "tool_result") or event["index"] < start_index:
            continue
        for raw in IMAGE_PATH_RE.findall(event["text"]):
            if raw in seen or not Path(raw).expanduser().is_file():
                continue
            seen.add(raw)
            images.append({"index": event["index"], "path": raw, "exists": True})
    return images


def _user_messages(events: list[dict], start_index: int, end_index: int | None) -> list[dict]:
    """User messages in the window + a few reactions after it (everything from start if no end_index)"""
    picked, after_window = [], 0
    for event in events:
        if event["kind"] != "user" or event["index"] <= start_index:
            continue
        if end_index is not None and event["index"] > end_index:
            if after_window >= USER_REACTIONS_AFTER_WINDOW:
                break
            after_window += 1
        picked.append(event)
    return picked


def _select_calls(calls: list[dict], results_by_id: dict, last: int, around: str | None) -> tuple[list[dict], bool]:
    """With around: last calls centered on the first match (half before); without it or no match: the last `last` calls"""
    if last <= 0:
        return [], False
    if around:
        for position, call in enumerate(calls):
            if around in call["text"] or around in results_by_id.get(call["tool_use_id"], ""):
                start = max(0, position - last // 2)
                return calls[start:start + last], True
    return calls[-last:], False


def build_excerpt(events: list[dict], last: int = 40, max_chars: int = 4000, around: str | None = None,
                  anchor_tool_use_id: str | None = None, window: int = 8) -> dict:
    """Excerpt around projectops calls (last `last`, or centered where the around text appears) + anchor call window (anchor_*). redactions holds counts per kind"""
    results_by_id = {e["tool_use_id"]: e["text"] for e in events if e["kind"] == "tool_result" and e["tool_use_id"]}
    calls = [e for e in events if e["kind"] == "tool_use" and e["tool_name"] != "Skill" and is_projectops_command(e["text"])]
    recent_calls, is_around_matched = _select_calls(calls, results_by_id, last, around)
    result_index_by_id = {e["tool_use_id"]: e["index"] for e in events if e["kind"] == "tool_result" and e["tool_use_id"]}
    end_index = None
    if is_around_matched:
        last_call = recent_calls[-1]
        end_index = result_index_by_id.get(last_call["tool_use_id"], last_call["index"])
    redactions: dict = {}

    # Command/result pairs
    steps = []
    for call in recent_calls:
        command, _, counts = _clip(call["text"], max_chars)
        _merge_counts(redactions, counts)
        raw_result = results_by_id.get(call["tool_use_id"], "")
        if any(marker in call["text"] for marker in OMITTED_COMMAND_MARKERS):
            raw_result = OMITTED_RESULT
        result, is_truncated, counts = _clip(raw_result, max_chars)
        _merge_counts(redactions, counts)
        steps.append({"index": call["index"], "command": command, "result": result, "truncated": is_truncated})

    # User messages after the first command (tool results excluded)
    start_index = recent_calls[0]["index"] if recent_calls else 0
    user_messages = []
    for event in _user_messages(events, start_index, end_index):
        if event["text"].strip():
            text, _, counts = _clip(event["text"], max_chars)
            _merge_counts(redactions, counts)
            user_messages.append({"index": event["index"], "text": text})

    skills_seen = list(dict.fromkeys(e["text"] for e in events if e["tool_name"] == "Skill" and e["text"]))
    anchor_part = build_anchor_window(events, results_by_id, anchor_tool_use_id, window, redactions)
    return {**anchor_part, "steps": steps, "user_messages": user_messages[-last:] if last > 0 else [],
            "skills_seen": skills_seen, "images": _image_paths(events, start_index),
            "total_projectops_calls": len(calls), "around_matched": is_around_matched, "redactions": redactions}


def build_anchor_window(events: list[dict], results_by_id: dict, anchor_tool_use_id: str | None, window: int,
                        redactions: dict) -> dict:
    """Anchor call > {anchor_matched, anchor (raw result), flow (all tool calls around it), agent_notes, setup_commands}"""
    tool_uses = [e for e in events if e["kind"] == "tool_use"]
    position = next((i for i, e in enumerate(tool_uses) if anchor_tool_use_id and e["tool_use_id"] == anchor_tool_use_id), None)
    if position is None:
        return {"anchor_matched": False}

    def clipped(text: str, limit: int) -> tuple[str, bool]:
        value, is_truncated, counts = _clip(text, limit)
        _merge_counts(redactions, counts)
        return value, is_truncated

    # Anchor call (raw result, only capped)
    anchor_event = tool_uses[position]
    command, _ = clipped(anchor_event["text"], ANCHOR_RESULT_MAX_CHARS)
    result, is_truncated = clipped(results_by_id.get(anchor_event["tool_use_id"], ""), ANCHOR_RESULT_MAX_CHARS)
    anchor = {"index": anchor_event["index"], "tool": anchor_event["tool_name"], "command": command,
              "result": result, "truncated": is_truncated}

    # Flow before and after (projectops or not · includes workaround commands)
    flow = []
    for event in tool_uses[max(0, position - window):position + window + 1]:
        flow_command, _ = clipped(event["text"], FLOW_RESULT_MAX_CHARS)
        flow_result, flow_truncated = clipped(results_by_id.get(event["tool_use_id"], ""), FLOW_RESULT_MAX_CHARS)
        flow.append({"index": event["index"], "tool": event["tool_name"], "is_anchor": event is anchor_event,
                     "command": flow_command, "result": flow_result, "truncated": flow_truncated})

    # Agent text in the same span (what it was trying to do)
    start_index, end_index = flow[0]["index"], flow[-1]["index"]
    agent_notes = []
    for event in events:
        if event["kind"] == "assistant_text" and start_index <= event["index"] <= end_index and event["text"].strip():
            note, _ = clipped(event["text"], AGENT_NOTE_MAX_CHARS)
            agent_notes.append({"index": event["index"], "text": note})

    # projectops commands before the anchor (commands that set up state: web open · device, etc.)
    setup_commands = []
    for event in tool_uses[:position]:
        if event["tool_name"] != "Skill" and is_projectops_command(event["text"]):
            setup_command, _ = clipped(event["text"], FLOW_RESULT_MAX_CHARS)
            setup_result, _ = clipped(results_by_id.get(event["tool_use_id"], ""), 300)
            setup_commands.append({"index": event["index"], "command": setup_command, "result_head": setup_result})
    return {"anchor_matched": True, "anchor": anchor, "flow": flow, "agent_notes": agent_notes,
            "setup_commands": setup_commands[-SETUP_COMMANDS_KEPT:]}
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: 470kUpdated 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