desloppify

repository·main·Indexed 24 days ago

https://github.com/peteromallet/desloppify

A multi-language codebase health scanner and technical debt tracker (version 1.0). It serves as an agent harness for AI coding agents to identify and improve code quality using mechanical detection and LLM-driven review. Features include a tiered Work Queue for managing issue lifecycles, framework-aware detection for Next.js (including 'next lint' integration), and comprehensive C# analysis for dependencies, circular references, and security vulnerabilities, with optional Roslyn integration for high-precision dependency graphs.

Tokens
61.3K
Snippets
111
Records
395
Agent score
83%

What's inside desloppify

  1. Understand Desloppify Architecture and Layers

    main

    Desloppify is organized into a layered architecture where each layer can only import from lower-numbered layers. This prevents circular dependencies and maintains a clear separation between foundational infrastructure and language-specific logic.

    • Layer 0: base/: Foundational infrastructure (path resolution, config, enums, output).
    • Layer 1: engine/detectors/: Generic analysis algorithms with zero language imports.
    • Layer 2: languages/_framework/: Shared contracts and helpers for normalizing results into tiered findings.
    • Layer 3: languages/<name>/: Language-specific configuration, phases, extractors, detectors, and fixers.
    • Layer 4: app/: CLI commands serving as thin entry points.
  2. Understand the Desloppify health score calculation

    main

    Desloppify computes a health score from 0 to 100. A score of 100 indicates no known issues. The score is a blend of two independent pools:

    • Mechanical (25% weight): Derived from automated detectors (e.g., code smells, duplication, security).
    • Subjective (75% weight): Derived from AI code review assessments (e.g., architecture, elegance, contracts).

    Note: If no subjective reviews have been run, the score is 100% mechanical. Once subjective dimensions are present, the 25/75 split is applied. Within each pool, dimensions are averaged using their own configured weights.

  3. Understand the Desloppify Language Plugin Tiers

    main

    Desloppify uses a two-tier plugin system for language support:

    1. Generic Plugins: Lightweight, single-file plugins (~20-40 lines) that wrap external linters (e.g., rubocop, eslint, shellcheck). When tree-sitter-language-pack is installed, they gain AST-powered analysis (complexity, dependency graphs, unused imports, etc.).
    2. Full Plugins: Comprehensive, multi-module packages with hand-written detectors, language-specific smell analysis, auto-fixers, and deep scoring. These are used for languages requiring deep idiomatic understanding (e.g., Python, TypeScript, Rust).

    Common capabilities for all plugins:

    • Security scanning
    • LLM-powered subjective design review
    • Boilerplate and duplicate detection
    • Zone classification (test/vendor/config/generated)
    • Automatic scoring integration
  4. Understand Next.js Framework Support in Desloppify

    main

    Desloppify provides framework-aware code quality detection for Next.js projects. It uses a combination of fast heuristic scanners (regex/file-structure based) and a slower next lint integration to catch smells that generic detectors miss.

    Key capabilities include detecting:

    • App Router vs. Pages Router misuse and migration signals.
    • Client/Server boundary violations (e.g., missing or misplaced "use client" or "use server" directives).
    • Server-only imports (like next/headers or server-only) appearing in client modules.
    • Environment variable leakage (using non-NEXT_PUBLIC_* variables in client modules).
    • Misuse of Next.js APIs in the wrong router context (e.g., using getServerSideProps in the App Router).
    • next lint integration for deep ESLint-based analysis.
  5. Understand the Review Pipeline stages

    main

    The Review Pipeline processes open Pull Requests (PRs) and Issues through three distinct stages to ensure high-quality code changes via symmetric scrutiny:

    1. Stage 1: Assess: Parallel sub-agents perform an honest assessment of each item and write results to <item-id>.json (e.g., pr-486.json).
    2. Stage 2: Challenge: Parallel sub-agents challenge the Stage 1 results.
      • Devil's Advocate: Challenges items Stage 1 accepted (default: NO).
      • Angel's Advocate: Advocates for items Stage 1 rejected (default: YES). Results are written to <item-id>.stage2.json (e.g., pr-486.stage2.json). The Stage 2 orchestrator also writes _cross-item.json to record duplicates and ordering.
    3. Stage 3: Adjudicate + Execute: A sequential process that reads both Stage 1 and Stage 2 files, weighs the arguments, forms an opinion, and executes actions (test, commit, comment, close).
  6. Configure a full C/C++ scan with Desloppify

    main

    To achieve the deepest and most accurate C/C++ analysis, Desloppify requires specific build metadata and external analyzers. A 'full' scan is achieved when the following four components are present:

    1. compile_commands.json: The primary input for dependency and include resolution. It should be placed at the repository root passed to the scan command.
    2. clang-tidy: Must be available on your PATH for security and CERT-style findings.
    3. cppcheck: Must be available on your PATH to power the cppcheck_issue phase.
    4. Python extras: The desloppify[full] package must be installed in your Python environment.

    If any of these are missing, the scan will degrade gracefully (e.g., falling back to regex-based heuristics or local include scanning) rather than failing, but the results will be less complete.

  7. Use Warm Server mode for parallel OpenCode reviews

    main

    To avoid MCP cold-start overhead during parallel runs, you can start a persistent OpenCode server and attach Desloppify to it using the DESLOPPIFY_OPENCODE_ATTACH environment variable. When this variable is set, batch subprocesses will attach to the running server via --attach <url> instead of spawning fresh instances.

    opencode serve --port 4096 &
    export DESLOPPIFY_OPENCODE_ATTACH=http://localhost:4096
    desloppify review --run-batches --runner opencode --parallel --scan-after-import
  8. Setup the review pipeline decision-making process

    main

    Before acting as a decision-maker in the review pipeline, perform these setup steps to ensure environment stability and data integrity:

    1. Verify Branch: Ensure you are on the release branch (not main) using git branch --show-current.
    2. Verify Working Tree: Ensure the tree is clean with git status.
    3. Run Tests: Execute python -m pytest desloppify/tests/ -q.
    4. Review Conventions: Read docs/CLAUDE.md for project-specific conventions.
    5. Validate Data: Run python review/validate.py --stage 2. If this fails, stop immediately.
    6. Inspect Results: List files in review/results/ to identify Stage 1 ({type}-{number}.json), Stage 2 ({type}-{number}.stage2.json), and cross-item (_cross-item.json) files.
    7. Identify Pending Items: Skip any items that already contain a stage3 section in their JSON file. To re-run an item, you must manually remove its stage3 section.
    git branch --show-current
    git status
    python -m pytest desloppify/tests/ -q
    python review/validate.py --stage 2
  9. Manually prepare and run an OpenCode review

    main

    If you need to control the review process manually, follow these two steps:

    1. Prepare: Generate the necessary review files (query.json and .desloppify/review_packet_blind.json) using the --prepare flag.
    2. Run batches: Execute the batch review process using the OpenCode runner.

    The runner automatically handles batch splitting, prompt generation, parallel execution, retry/stall detection, result extraction, merging, and trusted import.

    desloppify review --prepare
    desloppify review --run-batches --runner opencode --parallel --scan-after-import