Skip to content

notque/vexjoy-agent / skills/meta/toolkit

toolkit

Verified

Toolkit management: create and evaluate skills and agents, manage routing tables, generate Claude.md.

FileKindSize
SKILL.mdskill md15.5 KB
agents/skill-creator/analyzer.mdmarkdown4.8 KB
agents/skill-creator/comparator.mdmarkdown4.7 KB
agents/skill-creator/grader.mdmarkdown3.9 KB
assets/skill-creator/eval_viewer.htmlother57.1 KB
references/agent-comparison.mdmarkdown11.5 KB
references/agent-comparison/benchmark-tasks.mdmarkdown6.8 KB
references/agent-comparison/do-creation-compliance-tasks.jsonconfig8.5 KB
references/agent-comparison/examples-and-errors.mdmarkdown1.0 KB
references/agent-comparison/grading-rubric.mdmarkdown4.3 KB
references/agent-comparison/methodology.mdmarkdown7.4 KB
references/agent-comparison/optimization-guide.mdmarkdown12.0 KB
references/agent-comparison/optimization-tasks.example.jsonconfig853 B
references/agent-comparison/optimize-phase.mdmarkdown9.3 KB
references/agent-comparison/read-only-ops-short-tasks.jsonconfig375 B
references/agent-comparison/report-template.mdmarkdown3.8 KB
references/agent-comparison/socratic-debugging-body-short-tasks.jsonconfig372 B
references/agent-comparison/socratic-debugging-trigger-tasks.jsonconfig2.8 KB
references/agent-creator.mdmarkdown10.9 KB
references/agent-creator/agent-design-patterns.mdmarkdown12.4 KB
references/agent-creator/agent-eval-design.mdmarkdown7.7 KB
references/agent-creator/agent-frontmatter-template.mdmarkdown9.3 KB
references/agent-evaluation.mdmarkdown10.6 KB
references/agent-evaluation/batch-evaluation.mdmarkdown1.6 KB
references/agent-evaluation/common-issues.mdmarkdown2.1 KB
references/agent-evaluation/report-templates.mdmarkdown2.2 KB
references/agent-evaluation/scoring-rubric.mdmarkdown2.4 KB
references/blind-ab-tests.mdmarkdown7.8 KB
references/generate-claudemd.mdmarkdown11.0 KB
references/generate-claudemd/CLAUDEMD_TEMPLATE.mdmarkdown4.1 KB
references/generate-claudemd/examples-and-errors.mdmarkdown7.4 KB
references/github-profile-rules.mdmarkdown7.5 KB
references/github-profile-rules/github-api-patterns.mdmarkdown8.2 KB
references/github-profile-rules/rule-categories.mdmarkdown4.8 KB
references/hook-development.mdmarkdown10.9 KB
references/hook-development/architecture.mdmarkdown3.7 KB
references/hook-development/code-examples.mdmarkdown9.4 KB
references/hook-development/preferred-patterns.mdmarkdown6.5 KB
references/hook-development/telemetry-database.mdmarkdown6.5 KB
references/routing-table-updater.mdmarkdown10.2 KB
references/routing-table-updater/batch-mode.mdmarkdown2.1 KB
references/routing-table-updater/conflict-resolution.mdmarkdown3.8 KB
references/routing-table-updater/error-handling.mdmarkdown1.9 KB
references/routing-table-updater/examples.mdmarkdown4.8 KB
references/routing-table-updater/extraction-patterns.mdmarkdown2.2 KB
references/routing-table-updater/routing-format.mdmarkdown3.6 KB
references/routing-table-updater/skill-examples.mdmarkdown2.7 KB
references/skill-composer.mdmarkdown9.1 KB
references/skill-composer/compatibility-matrix.mdmarkdown13.0 KB
references/skill-composer/composition-patterns.mdmarkdown4.9 KB
references/skill-composer/examples.mdmarkdown17.1 KB
references/skill-composer/skill-patterns.mdmarkdown12.5 KB
references/skill-creator.mdmarkdown28.9 KB
references/skill-creator/agent-template.mdmarkdown18.5 KB
references/skill-creator/artifact-schemas.mdmarkdown8.2 KB
references/skill-creator/bundled-components.mdmarkdown2.3 KB
references/skill-creator/complexity-tiers.mdmarkdown8.0 KB
references/skill-creator/domain-research-targets.mdmarkdown13.2 KB
references/skill-creator/enrichment-workflow.mdmarkdown9.9 KB
references/skill-creator/error-catalog.mdmarkdown9.9 KB
references/skill-creator/preferred-patterns.mdmarkdown11.7 KB
references/skill-creator/progressive-disclosure.mdmarkdown8.5 KB
references/skill-creator/skill-template.mdmarkdown14.6 KB
references/skill-creator/workflow-patterns.mdmarkdown7.6 KB
references/system-upgrade.mdmarkdown11.0 KB
references/system-upgrade/component-audit-checklists.mdmarkdown8.4 KB
references/system-upgrade/upgrade-failure-modes.mdmarkdown8.7 KB
references/system-upgrade/upgrade-signal-parsing.mdmarkdown7.3 KB
references/toolkit-evolution.mdmarkdown14.5 KB
references/toolkit-evolution/diagnose-scripts.mdmarkdown9.5 KB
references/toolkit-evolution/evolution-history.mdmarkdown5.5 KB
references/toolkit-evolution/evolution-report-template.mdmarkdown716 B
references/toolkit-evolution/evolve-preferred-patterns.mdmarkdown6.9 KB
references/toolkit-evolution/evolve-scripts.mdmarkdown3.7 KB
references/toolkit-governance.mdmarkdown16.0 KB
references/toolkit-governance/adr-lifecycle.mdmarkdown10.9 KB
references/toolkit-governance/frontmatter-compliance.mdmarkdown11.1 KB
references/toolkit-governance/hook-standardization.mdmarkdown21.5 KB
references/toolkit-governance/routing-table-patterns.mdmarkdown11.6 KB
references/weak-model-uplift.mdmarkdown10.3 KB
scripts/agent-comparison/compare.pyscript2.3 KB
scripts/agent-comparison/generate_variant.pyscript19.6 KB
scripts/agent-comparison/optimize_loop.pyscript89.3 KB
scripts/agent-comparison/trigger_eval.pyscript19.5 KB
scripts/routing-table-updater/extract_metadata.pyscript10.8 KB
scripts/routing-table-updater/generate_routes.pyscript10.5 KB
scripts/routing-table-updater/scan.pyscript4.7 KB
scripts/routing-table-updater/update_routing.pyscript12.4 KB
scripts/routing-table-updater/validate.pyscript7.3 KB
scripts/skill-composer/build_dag.pyscript12.5 KB
scripts/skill-composer/discover_skills.pyscript12.1 KB
scripts/skill-composer/validate.pyscript12.3 KB
scripts/skill-creator/aggregate_benchmark.pyscript10.0 KB
scripts/skill-creator/eval_compare.pyscript10.2 KB
scripts/skill-creator/optimize_description.pyscript12.5 KB
scripts/skill-creator/package_results.pyscript7.8 KB
scripts/skill-creator/run_eval.pyscript6.3 KB

scripts/routing-table-updater/update_routing.py

View on GitHub
#!/usr/bin/env python3
"""
Update routing tables in commands/do.md with generated entries.
Preserves manual entries and creates backups.
"""

import argparse
import json
import re
import sys
from datetime import datetime
from pathlib import Path
from typing import Any, Dict, List, Tuple


class UpdateError(Exception):
    """Custom exception for update errors."""

    pass


def create_backup(target_file: Path, keep_count: int = 5) -> Path:
    """
    Create timestamped backup of target file and clean up old backups.

    Args:
        target_file: File to backup
        keep_count: Number of recent backups to keep (default: 5)

    Returns path to backup file.
    """
    timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
    backup_dir = target_file.parent
    backup_name = f".{target_file.name}.backup.{timestamp}"
    backup_path = backup_dir / backup_name

    # Copy file
    import shutil

    shutil.copy2(target_file, backup_path)

    # Clean up old backups (keep only most recent keep_count)
    backup_pattern = f".{target_file.name}.backup.*"
    backups = sorted(
        backup_dir.glob(backup_pattern),
        key=lambda p: p.stat().st_mtime,
        reverse=True,  # Most recent first
    )

    # Remove old backups beyond keep_count
    for old_backup in backups[keep_count:]:
        try:
            old_backup.unlink()
        except OSError:
            # Ignore errors deleting old backups
            pass

    return backup_path


def is_auto_generated_row(row: str) -> bool:
    """Check if table row is auto-generated."""
    return "[AUTO-GENERATED]" in row


def parse_markdown_table(lines: List[str], start_idx: int) -> Tuple[List[str], int]:
    """
    Parse markdown table starting at start_idx.

    Returns (table_rows, end_idx)
    """
    table_rows = []
    idx = start_idx

    # Find table end (first line that doesn't start with |)
    while idx < len(lines):
        line = lines[idx].strip()
        if not line.startswith("|"):
            break
        table_rows.append(line)
        idx += 1

    return table_rows, idx


def format_table_row(columns: List[str]) -> str:
    """Format list of columns as markdown table row."""
    # Ensure proper pipe formatting with type safety
    row = "| " + " | ".join(str(col) for col in columns) + " |"
    return row


def extract_manual_rows(table_rows: List[str]) -> List[str]:
    """Extract manual (non-auto-generated) rows from table."""
    manual_rows = []

    # Skip header (first 2 rows)
    for row in table_rows[2:]:
        if not is_auto_generated_row(row):
            manual_rows.append(row)

    return manual_rows


def generate_table_rows(entries: List[Dict[str, Any]], table_type: str) -> List[str]:
    """
    Generate table rows from routing entries.

    Returns list of markdown table row strings.
    """
    rows = []

    for entry in entries:
        if table_type == "Intent Detection Patterns":
            # | User Says | Route To | Complexity | [AUTO-GENERATED] |
            columns = [entry["user_says"], entry["route_to"], entry["complexity"], "[AUTO-GENERATED]"]

        elif table_type == "Domain-Specific Routing":
            # | Domain Mentioned | Agent | Typical Complexity | [AUTO-GENERATED] |
            columns = [entry["domain_mentioned"], entry["agent"], entry["typical_complexity"], "[AUTO-GENERATED]"]

        elif table_type == "Task Type Routing":
            # | Task Type | Route To Agent | Complexity | [AUTO-GENERATED] |
            columns = [entry["task_type"], entry["route_to"], entry["complexity"], "[AUTO-GENERATED]"]

        else:
            continue

        rows.append(format_table_row(columns))

    return rows


def update_table_in_content(
    content_lines: List[str], table_name: str, new_entries: List[Dict[str, Any]]
) -> Tuple[List[str], Dict[str, int]]:
    """
    Update a single routing table in content.

    Returns (updated_lines, stats)
    """
    # Find table header
    header_pattern = f"### {table_name}"
    table_start_idx = None

    for idx, line in enumerate(content_lines):
        if header_pattern in line:
            table_start_idx = idx
            break

    if table_start_idx is None:
        raise UpdateError(f"Table header not found: {header_pattern}")

    # Find table start (first line with |)
    table_data_start = None
    for idx in range(table_start_idx, min(table_start_idx + 10, len(content_lines))):
        if content_lines[idx].strip().startswith("|"):
            table_data_start = idx
            break

    if table_data_start is None:
        raise UpdateError(f"Table data not found after header: {header_pattern}")

    # Parse existing table
    existing_table, table_end_idx = parse_markdown_table(content_lines, table_data_start)

    # Extract manual rows (preserve them)
    manual_rows = extract_manual_rows(existing_table)

    # Generate new auto-generated rows
    auto_gen_rows = generate_table_rows(new_entries, table_name)

    # Combine: header (2 rows) + manual rows + auto-generated rows
    header_rows = existing_table[:2]  # Table header and separator
    new_table = header_rows + manual_rows + auto_gen_rows

    # Update content
    updated_lines = content_lines[:table_data_start] + new_table + content_lines[table_end_idx:]

    # Calculate stats
    stats = {
        "added": len(auto_gen_rows),
        "modified": 0,  # Simplified: all auto-gen treated as new
        "removed": 0,
        "manual_preserved": len(manual_rows),
    }

    return updated_lines, stats


def validate_markdown(content: str) -> Tuple[bool, List[str]]:
    """
    Validate markdown table syntax.

    Returns (is_valid, error_messages)
    """
    errors = []

    lines = content.split("\n")

    # Check for common table errors
    in_table = False
    table_col_count = None

    for line_num, line in enumerate(lines, 1):
        stripped = line.strip()

        if stripped.startswith("|"):
            in_table = True

            # Count pipes (columns)
            pipe_count = stripped.count("|")

            if table_col_count is None:
                table_col_count = pipe_count
            elif pipe_count != table_col_count:
                errors.append(
                    f"Line {line_num}: Inconsistent column count (expected {table_col_count}, got {pipe_count})"
                )

            # Check for trailing/leading spaces around pipes (skip separator rows)
            is_separator = re.match(r"^\|[-:| ]+\|$", stripped)
            if not is_separator:
                if not stripped.startswith("| "):
                    errors.append(f"Line {line_num}: Missing space after opening pipe")
                if not stripped.endswith(" |"):
                    errors.append(f"Line {line_num}: Missing space before closing pipe")

        elif in_table:
            # Exited table
            in_table = False
            table_col_count = None

    is_valid = len(errors) == 0
    return is_valid, errors


def generate_diff(original: str, updated: str) -> str:
    """Generate simple diff between original and updated content."""
    orig_lines = original.split("\n")
    updated_lines = updated.split("\n")

    diff_lines = []
    diff_lines.append("--- commands/do.md (original)")
    diff_lines.append("+++ commands/do.md (updated)")

    # Simple line-by-line diff
    for idx, (orig, upd) in enumerate(zip(orig_lines, updated_lines, strict=False), 1):
        if orig != upd:
            diff_lines.append(f"@@ Line {idx} @@")
            diff_lines.append(f"-{orig}")
            diff_lines.append(f"+{upd}")

    return "\n".join(diff_lines)


def main():
    """Main entry point."""
    parser = argparse.ArgumentParser(description="Update routing tables in commands/do.md")
    parser.add_argument("--input", type=Path, required=True, help="Input JSON from generate_routes.py")
    parser.add_argument("--target", type=Path, required=True, help="Target commands/do.md file path")
    parser.add_argument("--backup", action="store_true", help="Create backup before updating (recommended)")
    parser.add_argument("--dry-run", action="store_true", help="Show changes without modifying file")
    parser.add_argument("--auto-confirm", action="store_true", help="Skip interactive confirmation")
    parser.add_argument("--verbose", action="store_true", help="Enable verbose output to stderr")

    args = parser.parse_args()

    try:
        # Load routing entries
        if not args.input.exists():
            raise UpdateError(f"Input file not found: {args.input}")

        with open(args.input, "r", encoding="utf-8") as f:
            routes_data = json.load(f)

        if routes_data.get("status") != "success":
            raise UpdateError(f"Input routing data has error status: {routes_data.get('status')}")

        routing_entries = routes_data["routing_entries"]

        # Validate target file exists
        if not args.target.exists():
            raise UpdateError(f"Target file not found: {args.target}")

        # Read target file
        with open(args.target, "r", encoding="utf-8") as f:
            original_content = f.read()

        content_lines = original_content.split("\n")

        # Create backup
        backup_path = None
        if args.backup and not args.dry_run:
            backup_path = create_backup(args.target)
            if args.verbose:
                print(f"Backup created: {backup_path}", file=sys.stderr)

        # Update each table
        all_stats = {}
        updated_lines = content_lines

        for table_name, entries in routing_entries.items():
            if not entries:
                continue  # Skip empty tables

            if args.verbose:
                print(f"Updating table: {table_name}", file=sys.stderr)

            try:
                updated_lines, stats = update_table_in_content(updated_lines, table_name, entries)
                all_stats[table_name] = stats

            except UpdateError as e:
                print(f"WARNING: Could not update {table_name}: {e}", file=sys.stderr)
                continue

        # Generate updated content
        updated_content = "\n".join(updated_lines)

        # Validate markdown
        is_valid, validation_errors = validate_markdown(updated_content)
        if not is_valid:
            raise UpdateError("Markdown validation failed:\n" + "\n".join(validation_errors))

        # Generate diff
        diff = generate_diff(original_content, updated_content)

        # Show diff
        if args.verbose or args.dry_run:
            print("\n=== DIFF ===", file=sys.stderr)
            print(diff, file=sys.stderr)
            print("\n=== END DIFF ===\n", file=sys.stderr)

        # Interactive confirmation
        if not args.auto_confirm and not args.dry_run:
            print("\nRouting table updates ready:", file=sys.stderr)
            for table_name, stats in all_stats.items():
                print(
                    f"  - {table_name}: {stats['added']} new entries, {stats['manual_preserved']} manual preserved",
                    file=sys.stderr,
                )

            response = input("\nApply these changes? [y/N]: ")
            if response.lower() not in ["y", "yes"]:
                print("Update cancelled by user", file=sys.stderr)
                sys.exit(0)

        # Write updated content
        if not args.dry_run:
            with open(args.target, "w", encoding="utf-8") as f:
                f.write(updated_content)

            if args.verbose:
                print(f"Updated: {args.target}", file=sys.stderr)

        # Build result
        result = {
            "status": "success",
            "backup_created": str(backup_path) if backup_path else None,
            "changes_applied": all_stats,
            "validation_passed": True,
            "dry_run": args.dry_run,
        }

        # Output result
        print(json.dumps(result, indent=2, ensure_ascii=False))

    except UpdateError as e:
        # Attempt rollback if backup exists
        if backup_path and backup_path.exists():
            print("ERROR: Update failed, attempting rollback...", file=sys.stderr)
            import shutil

            shutil.copy2(backup_path, args.target)
            print("Rollback complete, restored from backup", file=sys.stderr)

        print(
            json.dumps({"status": "error", "error_type": "UpdateError", "message": str(e)}, indent=2), file=sys.stderr
        )
        sys.exit(1)

    except Exception as e:
        print(
            json.dumps({"status": "error", "error_type": type(e).__name__, "message": str(e)}, indent=2),
            file=sys.stderr,
        )
        sys.exit(2)


if __name__ == "__main__":
    main()
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