I need to understand what capabilities the full Python and TypeScript plugins have that the generic language plugins DON'T have. Research these areas:
Read desloppify/languages/framework/base/types.py to understand all fields on LangConfig — which ones are stubs for generic plugins?
Read desloppify/languages/framework/generic.py to see what's hardcoded/stubbed (look at the LangConfig constructor call and any noop_* or empty_* stubs)
Read desloppify/languages/_shared/phases_common.py to understand what shared phases exist and what they need
Read desloppify/languages/python/phases.py and desloppify/languages/typescript/phases.py to see what phases/detectors the full plugins run that generics don't
Read desloppify/languages/framework/base/phase_builders.py (or similar) to understand what shared phase builders exist
Check desloppify/engine/detectors/ for all cross-language detectors
Check what desloppify/languages/_shared/ contains
Summarize: what are ALL the capabilities that the full plugins have, and which of those could feasibly be added to generic plugins using tree-sitter? Focus on things that would add real value, not just check-a-box features.
Assistant
I'll systematically research the capabilities differences between full and generic language plugins. Let me start by reading the key architecture files.
Assistant
Now let me read the detector base file and the phases in Python and TypeScript:
Assistant
Now let me read the cross-language detectors and examine the framework phase builders:
Assistant
Let me read the shared_phases to understand what those phases do:
Assistant
Now let me examine what language-specific detectors exist in Python and TypeScript that aren't in the generic system:
Assistant
Let me look at [REDACTED] detectors to understand their value:
Assistant
Let me check tree-sitter integration to understand what generic plugins can now do:
Assistant
Let me read the tree-sitter integration and understand what it provides:
Assistant
Now let me look at a language-specific smells detector to understand what's not in the generic system:
Assistant
Perfect. Now let me compile a comprehensive research summary. Let me gather one more piece - what extractors exist:
Assistant
Perfect. Now I have all the information I need. Let me compile a comprehensive summary document.
COMPREHENSIVE RESEARCH REPORT: FULL vs. GENERIC LANGUAGE PLUGINS
Executive Summary
The full plugins (Python & TypeScript) have 3 major capability categories that generic plugins lack:
Language-specific deep analysis (AST/semantic, not regex-based)
Generic plugins with tree-sitter can now close ~50% of this gap by extracting functions and building dep graphs. However, they remain limited to regex-based smells detection and lack semantic enforcement.
PART 1: ARCHITECTURE OVERVIEW
LangConfig Fields (from types.py)
All language configs support these core fields:
Basic Setup:
name, extensions, exclusions, default_src
entry_patterns, barrel_names (for entry point detection)
build_dep_graph — CRITICAL: full plugins have real parsers; generics get empty_dep_graph()
extract_functions — CRITICAL: full plugins extract via AST; generics get noop_extract_functions()
zone_rules: list — production/test/config classification
review_* fields — design review caching and guidance
User
Research these files and summarize their patterns:
Find how god class detection works in the existing Python or TypeScript plugins. Search for "god_class" or "GodRule" usage. How is it wired into phases? What's the finding shape?
Read desloppify/engine/detectors/signature.py — how does signature_variance work? What does it need (functions list)?
Read desloppify/languages/framework/base/phase_builders.py or find detector_phase_security/detector_phase_test_coverage to see how shared phases are built
Search for "responsibility_cohesion" to see the Python implementation
Search for "unused_import" or "unused" detection in the Python plugin to understand that pattern
Read desloppify/languages/framework/finding_factories.py to see how findings are created from detector results
Give me the exact patterns I need to follow for: creating findings, wiring phases, GodRule usage, and the signature_variance API.
Assistant
I'll search for these patterns systematically across the codebase.
Assistant
Now let me read the key files to understand the patterns:
Assistant
Now let me check the phase builders and base detector to understand the GodRule pattern:
Assistant
Now let me look at how GodRule is used in the Python phases and how it's wired into the system:
Assistant
Now let me look at how the phase_gods function is structured:
Assistant
Let me look at the test to see how make_finding is called and the pattern for god-related findings:
Assistant
Now let me look at the make_finding function signature and understand it better:
Assistant
Perfect. Now let me read the complete make_finding function:
Assistant
Now let me check the signature.py more carefully and look at how unused detection works:
Assistant
Now let me look at how a phase function is structured by checking a complete example:
Assistant
Perfect! Let me look at how DetectorPhase is registered in the init.py:
Assistant
Excellent! Now let me look at one more critical piece - how findings are converted to Finding TypedDict:
Assistant
Perfect! Now I have all the information I need. Let me compile a comprehensive summary document.
Assistant
Perfect! Now I have all the information I need. Let me create a comprehensive summary.
Summary: Detector Patterns & Integration Guide
Based on my analysis of the codebase, here are the exact patterns you need to follow:
1. Creating Findings
The central function is make_finding() from desloppify.engine.state_internal.filtering:
python
make_finding(
detector: str, # e.g., "unused", "gods", "smells"
file: str, # absolute or relative path (converted via rel())
name: str, # "" for file-level, or unique identifier (e.g., class name)
*, # force keyword arguments
tier: int, # 1=quick fix, 2=medium, 3=judgment, 4=deep review
confidence: str, # "high", "medium", "low", "info"
summary: str, # 1-2 line user-facing description
detail: dict | None, # arbitrary metadata (default={})
) -> Finding # TypedDict with id, status, timestamps, etc.
Key properties of returned Finding:
id: Auto-generated as "{detector}::{rel_file}::{name}" or "{detector}::{rel_file}" if name is empty
status: Always set to "open" on creation
first_seen, last_seen, resolved_at: Auto-timestamps via utc_now()
reopen_count: Always 0 on creation
Example from TypeScript logs phase:
python
make_finding(
"logs",
file,
tag,
tier=1,
confidence="high",
summary=f"{len(entries)} tagged logs [{tag}]",
detail={"count": len(entries), "lines": [e["line"] for e in entries[:20]]},
)
User
Your task is to create a detailed summary of the conversation so far, paying close attention to the user's explicit requests and your previous actions.
This summary should be thorough in capturing technical details, code patterns, and architectural decisions that would be essential for continuing development work without losing context.
Before providing your final summary, wrap your analysis in tags to organize your thoughts and ensure you've covered all necessary points. In your analysis process:
Chronologically analyze each message and section of the conversation. For each section thoroughly identify:
The user's explicit requests and intents
Your approach to addressing the user's requests
Key decisions, technical concepts and code patterns
Specific details like:
file names
full code snippets
function signatures
file edits
Errors that you ran into and how you fixed them
Pay special attention to specific user feedback that you received, especially if the user told you to do something differently.
Double-check for technical accuracy and completeness, addressing each required element thoroughly.
Your summary should include the following sections:
Primary Request and Intent: Capture all of the user's explicit requests and intents in detail
Key Technical Concepts: List all important technical concepts, technologies, and frameworks discussed.
Files and Code Sections: Enumerate specific files and code sections examined, modified, or created. Pay special attention to the most recent messages and include full code snippets where applicable and include a summary of why this file read or edit is important.
Errors and fixes: List all errors that you ran into, and how you fixed them. Pay special attention to specific user feedback that you received, especially if the user told you to do something differently.
Problem Solving: Document problems solved and any ongoing troubleshooting efforts.
All user messages: List ALL user messages that are not tool results. These are critical for understanding the users' feedback and changing intent.
Pending Tasks: Outline any pending tasks that you have explicitly been asked to work on.
Current Work: Describe in detail precisely what was being worked on immediately before this summary request, paying special attention to the most recent messages from both user and assistant. Include file names and code snippets where applicable.
Optional Next Step: List the next step that you will take that is related to the most recent work you were doing. IMPORTANT: ensure that this step is DIRECTLY in line with the user's most recent explicit requests, and the task you were working on immediately before this summary request. If your last task was concluded, then only list next steps if they are explicitly in line with the users request. Do not start on tangential requests or really old requests that were already completed without confirming with the user first.
If there is a next step, include direct quotes from the most recent conversation showing exactly what task you were working on and where you left off. This should be verbatim to ensure there's no drift in task interpretation.
Assistant
First user message: "Implement the following plan:" — A detailed multi-step plan for Tree-Sitter Integration Round 2, covering:
Parse tree caching
New import resolvers (Bash, Perl, Zig, Haskell)
AST-based complexity signals
JavaScript plugin
Additional language plugins (Erlang, OCaml, F#)
Tests
I read all the key files to understand the codebase, then implemented all 5 steps of the plan plus tests. Key files read:
I created tasks 8-14 for this work and started implementing.
Completed so far (Items 1-7 partially):
Task 8 (Items 1, 3, 6) - COMPLETED: Added to :
User
I need to understand the upgrade path from a generic language plugin to a full language-specific plugin, comparing how Python and TypeScript plugins work vs the generic framework.
Specifically, find and summarize:
How do Python and TS plugins register themselves? (look at desloppify/languages/python/__init__.py and desloppify/languages/typescript/__init__.py)
What does a full plugin's LangConfig look like compared to generic_lang()? What extra fields/capabilities does it set?
How do Python/TS build their phases list? (look at phases.py in both)
How does desloppify/languages/framework/resolution.py resolve which plugin to use?
Can a generic plugin partially override individual phases? Or does it have to go full-custom?
What does desloppify/languages/framework/base/types.py LangConfig look like — what are all the fields?
How does desloppify/languages/__init__.py handle registration?
Focus on the architectural boundaries — what would someone need to do to take a generic plugin (e.g., Go) and upgrade specific parts to be language-specific while keeping the rest generic.
Assistant
I'll help you understand the upgrade path from generic to language-specific plugins. Let me explore the relevant files systematically.
Assistant
Now let me look at the phases builders and resolution logic:
Assistant
Now let me check the generic plugin implementation:
Assistant
Now let me check the discovery mechanism:
Assistant
Now let me check some real-world examples of how plugins override specific methods:
Assistant
Let me check the shared phase implementations to see how they call language-specific hooks:
Assistant
Now let me examine how C# is set up as a semi-full plugin example:
Assistant
Perfect! Now I have enough context. Let me also check the contract validation to understand what's required:
Assistant
Now let me check how plugin discovery works with different language types:
Assistant
Let me check how Go is registered as a plugin:
Assistant
Perfect! Now let me gather all the context by creating a comprehensive summary document. Let me check one more thing - how languages can be registered as "full" vs "generic":
Assistant
Perfect! Now I have all the information I need. Let me create a comprehensive summary document.
Language Plugin Architecture: Generic to Full-Custom Upgrade Path
Based on my analysis of the Desloppify codebase, here's a complete guide to the upgrade path from generic language plugins to full language-specific implementations.
1. Registration Mechanisms
Generic Plugins (single file or minimal package)
File: Lives in desloppify/languages/plugin_<name>.py OR a simple package directory
Registration: Call generic_lang() factory function from the plugin package __init__.py
Example (Go): /Users/user_c042661f/Documents/desloppify/desloppify/languages/go/__init__.py
python
from desloppify.languages.framework.generic import generic_lang
generic_lang(name="go", extensions=[".go"], tools=[...], depth="standard", ...)
Returns: A pre-built LangConfig instance (automatically registered)
Validation: Only contract validation via validate_lang_contract(), no package structure required
Compare the full language plugins (Python, TypeScript, C#, Dart, GDScript) against the generic tree-sitter framework to find functionality that's duplicated or could be replaced by the generic handlers.
The generic framework now provides these cross-language capabilities via tree-sitter:
Function extraction (duplicate detection)
Import parsing → dep graph → coupling/orphan/cycle detection
Nesting depth (AST-based)
Cyclomatic complexity per function
Long function detection
Parameter count
Callback/closure nesting depth
God class detection (methods > 15, LOC > 500, attributes > 10)
Empty catch/except block detection
Unreachable code after return/break/continue/throw
Responsibility cohesion (disconnected function clusters)
Unused import detection
Signature variance
For each full plugin, identify:
Which of these capabilities they implement manually (with the specific file/function)
Whether the manual implementation is better/worse/equivalent to the generic one
Whether the manual version handles language-specific edge cases the generic one can't
Focus on concrete overlap. Read the actual detector code, don't guess.
Also check languages/_shared/phases_common.py for shared phase runners that the full plugins use.
Assistant
I'll analyze the language plugins against the generic tree-sitter framework to identify duplicated or replaceable functionality. Let me start by exploring the key files.
Assistant
Let me use the correct tools to explore the structure first.
Assistant
Now let me read the key detector files systematically. Let me start with the shared framework and then check each full plugin.
Assistant
Now let me read the Python plugin phases and detectors:
Assistant
Now let me read the Python smells detectors and extractors:
Assistant
Let me read more and check the AST smells detectors:
Assistant
Now let me read the Python extractors:
Assistant
Now let me check TypeScript phases and detectors:
Assistant
Let me continue reading TypeScript phases and then check C#, Dart, GDScript:
Assistant
Now let me check the C#, Dart, and GDScript plugins:
Assistant
Now let me check the shared phases_common module:
Assistant
Now let me check tree-sitter extractors and the base detector types:
Assistant
Let me check TypeScript smells detection and extractors:
Assistant
Now let me get a summary of tree-sitter complexity detectors and tree-sitter smells:
Assistant
Now let me check what extractors each full plugin has:
Assistant
Perfect! Now I have a comprehensive picture. Let me create my analysis report by synthesizing what I've found:
Comprehensive Duplication Analysis: Full Language Plugins vs. Generic Tree-Sitter Framework
I've analyzed the Python, TypeScript, C#, Dart, and GDScript plugins against the generic tree-sitter framework. Here's what I found:
MAJOR FINDINGS: HIGH-VALUE CONSOLIDATION OPPORTUNITIES
1. Function & Class Extraction (CRITICAL OVERLAP)
Problem: Every full plugin reimplements function/class extraction manually.
Generic Alternative: languages/framework/treesitter/_extractors.py provides tree-sitter-based extraction that works across 15+ languages via make_ts_extractor().
Analysis:
Tree-sitter extracts: functions, params, return annotations, LOC — all standardized
Full plugins duplicate param extraction (each has custom _extract_params() logic)
All 5 plugins populate FunctionInfo with identical fields (name, file, line, loc, body, normalized, params, return_annotation)
Generic version is NOT worse: it's more robust (AST-based vs. regex/indentation)
Recommendation:
Replace Python/TypeScript/C#/Dart/GDScript extractors with tree-sitter wrappers
Keep language-specific extractors only for edge cases (e.g., C# generics in type annotations)
Cost: ~400 LOC reduction across 5 plugins
2. Structural Phase (DUPLICATE COMPLEXITY)
Problem: Large + complexity + god-class detection is reimplemented in every plugin.
Current State:
User
I need to understand exactly what TypeScript and C# structural/coupling phases do compared to the shared run_structural_phase() and run_coupling_phase() runners, to plan consolidation.
Read and summarize in detail:
desloppify/languages/typescript/phases.py — find _phase_structural and _phase_coupling. What exact calls do they make? What complexity signals, god rules, thresholds do they use? What's unique vs what's shared?
desloppify/languages/csharp/phases.py — find _phase_structural and any coupling phase. Same questions.
desloppify/languages/_shared/phases_common.py — read run_structural_phase() and run_coupling_phase() fully. What parameters do they accept? What signals/rules do they support?
desloppify/languages/dart/phases.py and desloppify/languages/gdscript/phases.py — how do they call the shared runners? What do they pass?
desloppify/engine/detectors/complexity.py — how does detect_complexity() work? What's the ComplexitySignal interface?
desloppify/engine/detectors/gods.py — how does detect_gods() work? What's the GodRule interface?
For each full plugin's structural phase, list:
The exact ComplexitySignal definitions (name, pattern, weight, threshold, compute)
The exact GodRule definitions (name, label, extractor, threshold)
Any custom logic not in the shared runner
The thresholds passed (min_loc, etc.)
I need this to understand whether the shared runner can accept the full plugin's configuration or needs extension.
Assistant
I'll systematically read through these files to understand the structural/coupling phase implementations.
Assistant
Now let me read the base types to understand ComplexitySignal and GodRule:
Assistant
Let me read the base types file:
User
I need to understand the extraction and smell detection overlap between full plugins and the generic tree-sitter framework.
Read and summarize:
desloppify/languages/python/extractors.py — how does it extract functions? What fields does it populate on FunctionInfo? Does it use AST or regex?
desloppify/languages/typescript/extractors.py — same questions. How does it handle arrow functions, methods, React components?
desloppify/languages/csharp/extractors.py — same questions.
desloppify/languages/dart/extractors.py — same questions.
desloppify/languages/gdscript/extractors.py — same questions.
For Python empty catch and unreachable code detection:
Read desloppify/languages/python/detectors/smells_ast/_tree_quality_detectors.py — find the empty except and unreachable code detectors. How do they work?
Are they part of the smells phase or a separate phase?
For TypeScript empty catch detection:
Read desloppify/languages/typescript/detectors/smells.py — find any catch-related detection.
Check whether any full plugin already has a tree-sitter spec available:
Read desloppify/languages/framework/treesitter/_specs.py — is there a PYTHON_SPEC, TYPESCRIPT_SPEC, CSHARP_SPEC, DART_SPEC, GDSCRIPT_SPEC?
The key question is: can the full plugins switch to tree-sitter extraction, or do they rely on language-specific extraction features the tree-sitter extractors don't provide?
Assistant
I'll analyze the extraction and smell detection overlap between full plugins and the generic tree-sitter framework. Let me start by reading all the extractor files and relevant detection code.
Assistant
Now let me check if there are any empty catch detectors in Python AST:
User
I need to understand two things:
TypeScript signature variance gap: Read desloppify/languages/typescript/phases.py and search for any call to detect_signature_variance or import of signature. Confirm it's missing. Then check how Python enables it — read desloppify/languages/python/phases_quality.py and find the signature variance call. What exact code enables it?
How tree-sitter phases could be enabled in full plugins:
Read desloppify/languages/framework/base/phase_builders.py — what shared phase builders exist? Is there a pattern for adding optional tree-sitter-powered phases to full plugins?
Read desloppify/languages/framework/base/shared_phases.py — what phases are shared here?
Can a full plugin add tree-sitter phases alongside its custom phases? Or does it need to replace things?
What phases each full plugin runs:
Read desloppify/languages/python/__init__.py — list ALL phases in order
Read desloppify/languages/typescript/__init__.py — list ALL phases in order
Read desloppify/languages/csharp/__init__.py — list ALL phases in order
Read desloppify/languages/dart/__init__.py — list ALL phases in order
Read desloppify/languages/gdscript/__init__.py — list ALL phases in order
What tree-sitter specs exist for full plugin languages: Check _specs.py for DART_SPEC, GDSCRIPT_SPEC, CSHARP_SPEC. Do they exist? Are they used by the plugins?
Assistant
Let me check the Python safety detector runtime file for silent except:
Assistant
I'll help you understand these aspects of the codebase. Let me start by reading the key files in parallel.
Assistant
Now let me check the context detectors to see if they cover the catch return pattern:
Assistant
Now let me read the phase_builders.py file and continue with the other files:
Assistant
Perfect. Now let me check if there's a "catch return default" detector in Python and verify the structure of the tree-sitter framework:
Assistant
Now let me read Dart and GDScript plugin files:
Assistant
Let me check the tree-sitter framework structure to understand if full plugins can use it:
Assistant
Good! Now let me check the _specs.py file to see what tree-sitter specs exist:
Assistant
Perfect! Now let me check how TypeScript's signature variance call compares to Python by looking at the actual signature detection call in both:
Assistant
Excellent! Both already have the call. Let me now verify if TypeScript is actually calling the signature variance detector by checking the phase_smells function more carefully:
Assistant
Now let me check if there's any smell detection capability in the tree-sitter framework:
Assistant
Perfect! Now I have all the information. Let me verify the Python phases structure by checking what's in the regular phases.py (not phases_quality.py):
Assistant
Perfect. Now let me create a comprehensive summary document. Since I'm in read-only mode, I'll provide the detailed analysis directly.
COMPREHENSIVE ANALYSIS: TypeScript vs C# Structural/Coupling Phases
ALSO callssignature_detector_mod.detect_signature_variance(functions) at line 34
Same location: in the phase_smells() function
Identical processing pattern
BUT: TypeScript imports it in phases.py (line 19):
python
from desloppify.engine.detectors import signature as signature_detector_mod
While the actual implementation happens in _phase_smells(), which both languages define. So signature variance IS enabled in both, but I suspect your question was whether it's wired into the Python plugin config—which it is, via _phase_smells being passed as a DetectorPhase.
Uses regex for function declarations, arrow functions, const assignments
Tracks braces with string-aware parsing (skips quoted strings)
Extracts params via _extract_ts_params() (handles destructuring, defaults, rest syntax)
FunctionInfo fields populated:
Same as Python: name, file, line, end_line, loc, body, normalized, body_hash, params
3. C# EXTRACTOR (extractors.py)
Extraction method: Regex + brace-matching
Uses regex _METHOD_DECL_RE to find methods/constructors
Brace-matching via _find_matching_brace() for body boundaries
Supports expression-bodied methods (=>) via _find_expression_end()
Extracts params via _extract_csharp_params()
FunctionInfo fields populated: Same 8 fields as Python/TypeScript
4. DART EXTRACTOR (extractors.py)
User
Your task is to create a detailed summary of the conversation so far, paying close attention to the user's explicit requests and your previous actions.
This summary should be thorough in capturing technical details, code patterns, and architectural decisions that would be essential for continuing development work without losing context.
Before providing your final summary, wrap your analysis in tags to organize your thoughts and ensure you've covered all necessary points. In your analysis process:
Chronologically analyze each message and section of the conversation. For each section thoroughly identify:
The user's explicit requests and intents
Your approach to addressing the user's requests
Key decisions, technical concepts and code patterns
Specific details like:
file names
full code snippets
function signatures
file edits
Errors that you ran into and how you fixed them
Pay special attention to specific user feedback that you received, especially if the user told you to do something differently.
Double-check for technical accuracy and completeness, addressing each required element thoroughly.
Your summary should include the following sections:
Primary Request and Intent: Capture all of the user's explicit requests and intents in detail
Key Technical Concepts: List all important technical concepts, technologies, and frameworks discussed.
Files and Code Sections: Enumerate specific files and code sections examined, modified, or created. Pay special attention to the most recent messages and include full code snippets where applicable and include a summary of why this file read or edit is important.
Errors and fixes: List all errors that you ran into, and how you fixed them. Pay special attention to specific user feedback that you received, especially if the user told you to do something differently.
Problem Solving: Document problems solved and any ongoing troubleshooting efforts.
All user messages: List ALL user messages that are not tool results. These are critical for understanding the users' feedback and changing intent.
Pending Tasks: Outline any pending tasks that you have explicitly been asked to work on.
Current Work: Describe in detail precisely what was being worked on immediately before this summary request, paying special attention to the most recent messages from both user and assistant. Include file names and code snippets where applicable.
Optional Next Step: List the next step that you will take that is related to the most recent work you were doing. IMPORTANT: ensure that this step is DIRECTLY in line with the user's most recent explicit requests, and the task you were working on immediately before this summary request. If your last task was concluded, then only list next steps if they are explicitly in line with the users request. Do not start on tangential requests or really old requests that were already completed without confirming with the user first.
If there is a next step, include direct quotes from the most recent conversation showing exactly what task you were working on and where you left off. This should be verbatim to ensure there's no drift in task interpretation.
Assistant
First context: This is a continuation of a previous conversation. The summary tells us that Round 1 (tree-sitter integration: parse cache, import resolvers, AST complexity, JS plugin, Erlang/OCaml/F# plugins) was completed. Round 2 items 1-7 (complexity signals, god class detection, AST smell detectors, cohesion) were partially done. Items 8 (unused imports), 9 (signature variance), and 14 (wiring + tests) were pending.
My first actions: I continued from where left off:
Marked Task 11 (cohesion) completed
Created _unused_imports.py (Task 12) - unused import detection via tree-sitter
Created 4 new phase factory functions in generic.py: _make_ast_smells_phase(), _make_cohesion_phase(), _make_unused_imports_phase(), _make_signature_phase()
Wired all 4 new phases into generic_lang()
Updated SHARED_PHASE_LABELS
Added comprehensive tests (42 new tests, 123 total)
All tests passed (2940 passed, 6 pre-existing failures)
User: "is there deeper stuff we could add to the long-tail of languages?" - Already answered in previous session.
User: "is it easy to replace generic stuff with language specific things like we have for python?"
I launched an Explore agent to research the upgrade path
Provided a detailed explanation of the three tiers (generic, generic + hooks, full plugin)
Explained the upgrade path and what stays shared
User: "is it obvious from the language README how to extend/improve languages"
I read the README and found it only documented full plugin architecture
Rewrote the README to document all three plugin tiers, tree-sitter integration, and the upgrade path
User: "Should the other languages mirror the main language structure?"
This came as a follow-up while I was editing
I addressed it in the README update: "Generic plugins should NOT mirror the full plugin directory structure."
User: "Does it explain how to extend/improve languages?"
I realized the README still didn't explain HOW to extend existing plugins
Added a comprehensive "Extending existing plugins" section with 6 concrete recipes
extractors_components.py — Passthrough components (just forward props, no value add)
Identifies:
Props interfaces on types, contexts, state types
Components that only {...props} forward
Ratio of direct props to forwarded props
Phase 6: Mixed Concerns
Detector:concerns.py
Flags .tsx files mixing multiple layers:
JSX rendering + data fetching + transformation + state management
Example: Component directly calling supabase.from() instead of a hook
Phase 7: Pattern Consistency
Detector:patterns.py
Detects competing approaches to the same problem within an area:
Tool settings: useAutoSaveSettings vs usePersistentToolState vs useToolSettings
Error handling: different toast/modal/redirect patterns
State management: useState vs useReducer vs custom hooks
Key insight: Complementary layers (useQuery + useMutation + one-off fetch) are OK. Competing patterns (2+ ways to persist settings in one area) suggest fragmentation.
Sets integration_depth = "standard" (vs "shallow" if tree-sitter unavailable)
PART 6: REAL VALUE ASSESSMENT — WHAT'S ACTUALLY WORTH ADDING
HIGH VALUE — Worth Bringing to Generics
1. React Hook Detection (TS only, 2026 addition)
Current: 6 React detectors in TS plugin
Why valuable: React is ubiquitous; hook anti-patterns affect performance/correctness
Feasibility: Medium — tree-sitter can extract hook calls, but proper detection needs semantic understanding of state dependencies
Effort: 2-3 weeks to build reliable heuristics
Specific patterns that would help generics:
useEffect without dependency array or with stale captures
useState for derived state (should be computed)
Deep provider nesting (tree traversal possible with tree-sitter)
Current:patterns.py — competing tool settings approaches
Why valuable: Early warning for architectural drift (2+ ways to solve the same problem)
Feasibility: Medium — requires domain-specific pattern library, but regex-based detection works
Effort: 2-4 weeks to define pattern families + detection rules
Could be generic: Yes, via user-provided pattern library config
Current:private_imports.py — detects _module imports from outside
Why valuable: Prevents internal API leakage
Feasibility: High — pure name-based, no semantics needed
Effort: 1 week
Could be generic: Yes, as simple regex rule on import paths
4. Mixed Concerns Detection (TS only, Python N/A)
Current:concerns.py — JSX + data fetching + transforms in one file
Why valuable: Structural smell indicating need for refactoring
Feasibility: High — regex patterns for concern markers (useQuery, supabase., .map, etc.)
Effort: 1 week
Could be generic: Yes, as configurable pattern library (what domain markers = data layer vs UI?)
MEDIUM VALUE — Useful but Language-Specific
5. Mutable State Tracking (Python only, no TS equivalent)
Current:mutable_state.py — module-level mutable collections
Why valuable: Catches non-determinism, test isolation issues
Feasibility: Low — requires control-flow analysis (Python-specific AST visitor pattern)
Effort: 2-3 weeks to implement for another language (if even possible in that lang)
Could be generic: Partially — tree-sitter can find module-level assignments, but tracking mutations requires control flow
6. Dict Key Lifecycle (Python only, no TS equivalent)
Current:dict_keys.py — dead writes, phantom reads, typos
Why valuable: Prevents data loss from misspelled keys
Feasibility: Very Low — requires sophisticated flow analysis
Effort: 4-6 weeks minimum for one language
Could be generic: No — language-specific to dynamic dispatch languages
7. Responsibility Cohesion (Python only, no TS equivalent)
Current:responsibility_cohesion.py — disconnected function clusters in a file
Why valuable: Detects "dumping ground" modules
Feasibility: Medium — requires call graph within a file
Effort: 2-3 weeks with tree-sitter function extraction
Could be generic: Yes, using tree-sitter to extract functions + local call analysis
8. Implicit Mixin Contracts (Python only, no TS equivalent)
Current:coupling_contracts.py — classes with undeclared self attributes
Why valuable: Prevents "duck-typing gone wrong" patterns
Feasibility: Low — requires class inheritance analysis + attribute tracking
Effort: 3-4 weeks for even one language
Could be generic: No — too language-specific
LOW VALUE — Overly Specific or Already Solved
9. Deprecated Symbols Tracking (TS only)
Already solved by linters (ESLint, TSLint). Not valuable to duplicate.
Bottom line: With tree-sitter + smart pattern libraries, generic plugins can deliver 70-80% of full-plugin value. The remaining 20% requires language-specific semantic analysis (not worth the effort for generics).
The 3 highest-impact additions for generics are:
React hook metrics (already exist in TS, just export)
detector_phase_*() and shared_subjective_duplicates_tail()
Wire in Config
LangConfig.phases list
DetectorPhase(...) or call builder function
Finding Factory
languages.framework.finding_factories
make_*_findings(entries, log) → list[Finding]
LangRun Context
Passed to phase runners
Access .zone_map, .dep_graph, .extract_functions, etc.
This covers all the exact patterns you need to follow for detector integration!
Here's an example of how your output should be structured:
Key Technical Concepts:
[Concept 1]
[Concept 2]
[...]
Files and Code Sections:
[File Name 1]
[Summary of why this file is important]
[Summary of the changes made to this file, if any]
[Important Code Snippet]
[File Name 2]
[Important Code Snippet]
[...]
Errors and fixes:
[Detailed description of error 1]:
[How you fixed the error]
[User feedback on the error if any]
[...]
Problem Solving:
[Description of solved problems and ongoing troubleshooting]
All user messages:
[Detailed non tool use user message]
[...]
Pending Tasks:
[Task 1]
[Task 2]
[...]
Current Work:
[Precise description of current work]
Optional Next Step:
[Optional Next step to take]
Please provide your summary based on the conversation so far, following this structure and ensuring precision and thoroughness in your response.
There may be additional summarization instructions provided in the included context. If so, remember to follow these instructions when creating the above summary. Examples of instructions include:
Compact Instructions
When summarizing the conversation focus on typescript code changes and also remember the mistakes you made and how you fixed them.
IMPORTANT: Do NOT use any tools. You MUST respond with ONLY the ... block as your text output.
_complexity.py
make_max_params_compute() — finds max parameter count across functions in a file
make_cyclomatic_complexity_compute() — counts decision points (if/for/while/case/catch/&&/||) per function
Wired detect_gods() call into _make_structural_phase() run function
Updated _make_structural_phase signature to accept file_finder parameter
Task 10 (Items 4, 5) - COMPLETED: Created _smells.py:
detect_empty_catches() — finds empty catch/except/rescue blocks via AST traversal
detect_unreachable_code() — finds code after return/break/continue/throw in statement sequences
Task 11 (Item 7) - COMPLETED (file written): Created _cohesion.py:
detect_responsibility_cohesion() — extracts functions, builds intra-file call graph via regex word boundary matching, finds connected components via BFS, flags files with 5+ clusters
NOT YET DONE:
Task 12 (Item 8): Unused imports detector
Task 13 (Item 9): Signature variance wiring
Task 14: Wire all new phases (items 4,5,7,8,9) into generic_lang(), register detectors/scoring policies, write tests, run full suite
Note: Items 1-3, 6 are complexity signals already wired into the structural phase. Items 4, 5, 7, 8, 9 need to be wired as separate phase(s) or integrated into existing phases in generic_lang().
The system reminder noted that test_treesitter.py was modified by a linter (removed os, tempfile, Path imports, and TreeSitterLangSpec import). Need to be aware of this.
Important patterns for remaining work:
Findings are created via make_finding(detector, file, name, *, tier, confidence, summary, detail)
desloppify/languages/framework/treesitter/_cohesion.py — NEW
detect_responsibility_cohesion(file_list, spec, *, min_loc=200) — extracts functions, builds intra-file call graph via regex word boundary, finds connected components via BFS, flags files with 5+ clusters
Errors and Fixes:
OCaml class query error: tree_sitter.QueryError: Impossible pattern at row 2, column 17 — the OCaml grammar's module_binding doesn't have name: as a named field. Fixed by changing name: (module_name) @name to just (module_name) @name.
Erlang function extraction returning 0 functions: The test fixture had functions too short (< 3 normalized lines, filtered by the len(normalized.splitlines()) < 3 check in ts_extract_functions). Fixed by making test functions have more lines.
Pre-existing test failure: test_legacy_assets_badge_path_migrates_to_root_default in test_config.py — unrelated to our changes, deselected during test runs.
Compute function TypeError: Existing compute functions (Python's compute_nesting_depth, etc.) don't accept _filepath kwarg. Fixed by using try/except in detect_complexity():
python
try:
result = sig.compute(content, lines, _filepath=filepath)
except TypeError:
result = sig.compute(content, lines)
Problem Solving:
Round 1 plan was fully implemented and all 2941 tests pass (3 skipped, 1 deselected pre-existing)
Round 2 items 1-7 have their core implementation written but items 4, 5, 7 need to be wired as phases into generic_lang()
Items 8 (unused imports) and 9 (signature variance) have not been started yet
None of the Round 2 items have tests yet
Round 2 detector/scoring registration has not been done yet
All User Messages:
"Implement the following plan: [detailed 5-step plan for Tree-Sitter Integration Round 2]"
"is there deeper stuff we could add to the long-tail of languages?"
Task 13: Wire signature variance into generic plugins (Item 9) — add phase using existing detect_signature_variance
Task 14: Wire ALL new phases (items 4, 5, 7, 8, 9) into generic_lang(), register detectors/scoring policies, write comprehensive tests, run full test suite
Specifically for Task 14, the following needs to happen:
Create a new phase function (e.g., _make_ast_smells_phase()) that calls detect_empty_catches, detect_unreachable_code from _smells.py
Create a new phase function for responsibility cohesion that calls detect_responsibility_cohesion from _cohesion.py
Create a new phase for unused imports
Create a new phase for signature variance
Register all new detectors via register_detector(DetectorMeta(...))
Register scoring policies via register_scoring_policy(DetectorScoringPolicy(...))
Add all new phases to the phases list in generic_lang()
Write tests for all new detectors
Run full test suite
Current Work:
I was working on implementing items 1-9 for the "deeper stuff" for long-tail languages. I had just completed writing _cohesion.py (Task 11, Item 7) and was about to move to Task 12 (Item 8: unused imports detector). The task list shows:
Optional Next Step:
Continue implementing the remaining items from the user's request "Let's do all of them for 1-9":
Complete Task 11 (mark completed)
Task 12: Create _unused_imports.py — unused imports detector that cross-references tree-sitter parsed imports against file body to find imports whose names don't appear elsewhere in the file
Task 13: Wire detect_signature_variance from engine/detectors/signature.py into a new phase in generic_lang()
Task 14: Wire all new detectors (_smells, _cohesion, unused_imports, signature_variance) as phases into generic_lang(), register detectors/scoring, write tests, run full suite
Discovery Process
Happens via load_all() in discovery.py, called lazily by resolution.py
Discovers plugins in this order:
plugin_*.py files (single-file generic plugins)
Package directories (full plugins with __init__.py)
User plugins from PROJECT_ROOT/.desloppify/plugins/*.py
All errors are collected and raised together after discovery attempt
2. LangConfig: Full Field Breakdown
The complete LangConfig dataclass (in base/types.py, lines 79-150) contains:
Returns class unchanged (for backward compat in tests)
Generic Registration (register_generic_lang())
python
from desloppify.languages import register_generic_lang
cfg = generic_lang("go", extensions=[".go"], tools=[...], depth="standard", ...)
# cfg is already in registry, but you could also:
register_generic_lang("mygo", cfg)
Differences from @register_lang:
No package structure validation (lives in plugin_go.py, a single file)
Only contract validation
Typically called by generic_lang() factory at end
Plugin Discovery (load_all())
Scans /desloppify/languages/ for plugin_*.py files → import as modules
Scans /desloppify/languages/ for subdirs with __init__.py → import as packages
Scans PROJECT_ROOT/.desloppify/plugins/ for user plugins
Collects all import errors, re-raises at end
Sets _load_attempted = True to prevent re-discovery
How init.py in languages/
python
# desloppify/languages/__init__.py (lines 30-54)
def register_lang(name: str) -> Callable[[T], T]:
"""Decorator to validate structure + contract, then instantiate + store."""
def decorator(cls: T) -> T:
module = inspect.getmodule(cls)
if module and hasattr(module, "__file__"):
validate_lang_structure(Path(module.__file__).parent, name)
if isinstance(cls, type) and issubclass(cls, LangConfig):
cfg = make_lang_config(name, cls)
registry_state._registry[name] = cfg
else:
registry_state._registry[name] = cls # test double
return cls
return decorator
Key insight: Stores instances, not classes. Test doubles that are classes are instantiated on demand by make_lang_config().
The Dart and GDScript plugins have already been refactored to use shared phase runners (run_structural_phase, run_coupling_phase). TypeScript and C# are lagging behind with duplicated structural logic. Python is split due to unique detectors but could benefit from tree-sitter migration for function extraction.
The tree-sitter framework is significantly more capable than manual implementations in several areas (nesting depth AST traversal, cyclomatic complexity, callback nesting), but adoption is optional because the manual versions work. The low-hanging fruit is consolidating the structural+coupling phases across TS and C#, which would free up 200+ LOC and reduce maintenance burden.
Pattern for adding tree-sitter phases: Full plugins can supplement their custom phases by calling shared_phase_builders.py helpers. They do NOT replace—they extend. For example, Python adds detector_phase_test_coverage()alongside its custom _phase_structural, _phase_coupling, etc.
Usage: All three full plugins define extract_functions callbacks that call tree-sitter-powered extractors (e.g., extract_csharp_functions(), extract_functions() for Dart/GDScript), which enables tree-sitter-based duplicate detection via phase_dupes() at scan time.
Key Insight
All full plugins (C#, Dart, GDScript) already leverage tree-sitter specs through:
Tree-sitter grammar definitions in _specs.py
Extractors that parse the AST (e.g., extract_csharp_functions, extract_functions)
Shared phase runners (phase_dupes, phase_test_coverage) that consume extracted functions
Dependency graph building via tree-sitter imports
They don't need "optional tree-sitter phases"—tree-sitter is the foundation of their extractors.
Extraction method: Regex + brace-matching
Uses regex for function declarations, supports decorators, async
Brace-matching for { bodies or => expressions
Indentation-based fallback for body extent
Extracts params via _extract_params() (simple split-based)
FunctionInfo fields populated: Same 8 fields
5. GDSCRIPT EXTRACTOR (extractors.py)
Extraction method: Regex + indentation-based
Uses regex r"(?m)^(\s*)func\s+([A-Za-z_]\w*)\s*\(([^)]*)\)\s*:" for function declaration
Indentation-based body extent via _block_end_line()
Extracts params via simple split-based _extract_params()
NOT available via tree-sitter (would require language-specific AST queries)
Missing from tree-sitter framework
Parameter extraction (tree-sitter does extract params via _extract_param_names())
Return type annotation extraction
"Catch returns default object" detection
Language-specific security/style detectors
Unreachable code detection (would need flow-control aware AST walking)
CAN FULL PLUGINS SWITCH TO TREE-SITTER?
Short answer: Only partially, and with significant trade-offs.
For extraction:
C#, Dart, GDScript: YES — tree-sitter extraction is available and working
Python, TypeScript: NO SPECS in tree-sitter (but could be added)
Catch: All 5 languages would lose language-specific detector features (security checks, React hooks, Python AST smell detectors)
For smell detection:
NO — tree-sitter framework only provides empty catch detection
Python's 20+ AST detectors have no tree-sitter equivalent
TypeScript's complex multi-line detectors (async_no_await, dead_useeffects, etc.) cannot be expressed in tree-sitter queries
Final verdict: The full plugins should remain independent because:
Python/TypeScript have no tree-sitter specs defined
Smell detection is inherently language-specific and AST-semantic (not tree-sitter-queryable)
Parameter extraction already works well in full plugins
Tree-sitter provides minimal benefit (only empty catch detection is shared)
Here's an example of how your output should be structured:
Key Technical Concepts:
[Concept 1]
[Concept 2]
[...]
Files and Code Sections:
[File Name 1]
[Summary of why this file is important]
[Summary of the changes made to this file, if any]
[Important Code Snippet]
[File Name 2]
[Important Code Snippet]
[...]
Errors and fixes:
[Detailed description of error 1]:
[How you fixed the error]
[User feedback on the error if any]
[...]
Problem Solving:
[Description of solved problems and ongoing troubleshooting]
All user messages:
[Detailed non tool use user message]
[...]
Pending Tasks:
[Task 1]
[Task 2]
[...]
Current Work:
[Precise description of current work]
Optional Next Step:
[Optional Next step to take]
Please provide your summary based on the conversation so far, following this structure and ensuring precision and thoroughness in your response.
There may be additional summarization instructions provided in the included context. If so, remember to follow these instructions when creating the above summary. Examples of instructions include:
Compact Instructions
When summarizing the conversation focus on typescript code changes and also remember the mistakes you made and how you fixed them.
IMPORTANT: Do NOT use any tools. You MUST respond with ONLY the ... block as your text output.
User: "is there any stuff in the main languages that could be done by the generic handlers?"
Launched an Explore agent to find overlap
Provided a detailed summary table of duplication
Identified actionable consolidation steps
User: "can you make a holistic plan here?"
Entered plan mode
Launched 3 parallel Explore agents:
TS/C# structural/coupling phases vs shared runners
Extractors + smells overlap
TS signature gap + enablement + phase lists
Read phases_common.py and csharp/phases.py in detail
Was in the process of synthesizing findings into a plan when summary was requested
Key findings from exploration:
TS signature variance is NOT missing (it's in _phase_smells()) - earlier analysis was wrong
C# structural phase is nearly identical to shared runner + god rules + 3 custom compute functions
C# coupling phase is shared runner + actionability gates
All full plugins already have tree-sitter specs (C#, Dart, GDScript)
Python/TS do NOT have tree-sitter specs
The shared run_structural_phase() doesn't support god rules (would need extension)
The shared run_coupling_phase() doesn't support actionability gates (would need extension)
Current state: In plan mode, having gathered all research, about to write the plan for consolidating full plugins to use generic handlers where appropriate.
Key Technical Concepts:
Three plugin tiers: Generic (generic_lang()), Generic + hooks, Full (@register_lang())
Tree-sitter integration: TreeSitterLangSpec with grammar, function_query, import_query, resolve_import, class_query
Shared phase runners: run_structural_phase() and run_coupling_phase() in _shared/phases_common.py
ComplexitySignal: (name, pattern, weight, threshold, compute) — used by detect_complexity()
GodRule: (name, description, extract, threshold) — used by detect_gods()
DetectorPhase: (label, run_fn) where run_fn(path, lang) -> (findings, potentials)
Does NOT support: god rules, custom detectors, actionability gates
desloppify/languages/csharp/phases.py — Read for consolidation analysis
_phase_structural: 60 lines of code nearly identical to run_structural_phase() PLUS god class detection (4 CSHARP_GOD_RULES) and 3 custom compute functions (_compute_max_nesting, _compute_method_count, _compute_long_methods)
_phase_coupling: 45 lines nearly identical to run_coupling_phase() PLUS _apply_csharp_actionability_gates() for confidence adjustment
Key C# god rules: methods>15, attributes>10, base_classes>4, long_methods(>50 LOC)>2
desloppify/engine/detectors/signature.py — Read for reference
detect_signature_variance(functions, min_occurrences=3) — groups by name, compares param signatures
TS already calls this in _phase_smells() (earlier analysis that it was missing was WRONG)
Errors and fixes:
TS signature variance gap was a false finding: The exploration agent initially reported TS was missing signature variance. A second exploration confirmed it IS present in _phase_smells() at line 567 of typescript/phases.py. No code change needed.
Pre-existing test failures: 6 tests fail (test_cmd_plan, test_cmd_zone, test_config) — confirmed unrelated to changes by checking git diff HEAD showed no modifications to those test files.
Pre-existing import error: test_ts_react.py has a broken import (detect_state_sync) — excluded from test runs.
Problem Solving:
Completed all 9 items for Round 2 deep analysis (tasks 8-14)
All 123 treesitter tests pass, 2940 total tests pass
README documentation gap identified and fixed
Comprehensive overlap analysis between full plugins and generic framework completed
Currently in plan mode designing consolidation strategy
All user messages:
(Continuation from previous session — items 1-9 implementation was ongoing)
"is it easy to replace generic stuff with language specific things like we have for python?"
"is it obvious from the language README how to extend/improve languages"
"Should the other languages mirror the main language structure?"
"Does it explain how to extend/improve languages?"
"is there any stuff in the main languages that could be done by the generic handlers?"
"can you make a holistic plan here?"
Pending Tasks:
Write and finalize the consolidation plan (currently in plan mode) — user asked "can you make a holistic plan here?" for consolidating full plugin code that duplicates generic framework capabilities
The plan should cover: extending shared runners to accept god rules + actionability gates, migrating C# structural/coupling phases, enabling tree-sitter phases in full plugins, and documenting the approach
Current Work:
I am in plan mode, having completed Phase 1 (exploration) with 3 parallel Explore agents and additional file reads. I've gathered comprehensive information about:
What TS/C# structural and coupling phases do vs shared runners
What extractors and smell detectors exist in each full plugin
What tree-sitter specs exist for full plugin languages
Whether TS signature variance is actually missing (it's not)
I was about to enter Phase 2 (design) — synthesizing findings into a concrete plan and writing it to the plan file at /Users/user_c042661f/.claude/plans/humble-riding-scroll.md.
Key consolidation findings ready to be planned:
C# structural phase: Can migrate to run_structural_phase() if it's extended to accept god_rules + god_extractor_fn
C# coupling phase: Can migrate to run_coupling_phase() if it's extended to accept post_process_fn for actionability gates
Dart/GDScript: Already use shared runners — good as-is
Tree-sitter phases (empty catch, unreachable code, cohesion): Can be enabled for C#/Dart/GDScript alongside existing phases
C# custom computes (_compute_max_nesting, _compute_method_count, _compute_long_methods): Could be replaced by tree-sitter complexity signals
Optional Next Step:
Write the consolidation plan to the plan file and call ExitPlanMode. The user's most recent request was: "can you make a holistic plan here?" — referring to consolidating full plugin code that duplicates the generic tree-sitter framework. I need to:
Launch a Plan agent (or write directly) to design the implementation approach
Write the plan to /Users/user_c042661f/.claude/plans/humble-riding-scroll.md