I need to understand the current framework detection and plugin architecture in this codebase. Please find and summarize:
How DetectorPhase is defined and used
How tree-sitter specs work (the horizontal layer pattern) - look for treesitter_spec, all_treesitter_phases
How generic_lang works for shallow plugins
How deep plugins like typescript define their phases
The LangRuntimeContract - what it provides
How tool specs (ToolSpec, make_tool_phase) work
Any existing framework detection code (look for next.js, react, framework)
The zone map and dep graph - how they're exposed
Be thorough - read the key files to understand the patterns.
Assistant
I'll systematically explore the codebase to understand the framework detection and plugin architecture. Let me start with a broad search for the key components you mentioned.
Assistant
Let me narrow the search to the source code directory:
Assistant
Now let me search for the key files mentioned in your request:
Assistant
Good! Now let me read the key files to understand the architecture:
Assistant
Now let me explore the treesitter and generic_lang frameworks:
Assistant
Now let me check the tool factories and TypeScript's phase definitions:
Assistant
Now let me search for framework detection code and zone/dep graph exposure:
Assistant
Let me continue reading the zones file and search for React framework detection:
Assistant
Now let me look at the framework.py file and understand how plugins are built:
Assistant
Now let me check how phase builders work and what the treesitter specs look like:
Assistant
Let me look at a couple of example full plugin implementations and the registration system:
Assistant
Now let me check how the dep graph and zone map are exposed/accessed:
Assistant
Now let me look at how dep_graph and zone_map are actually built and exposed to the rest of the system:
Assistant
Let me look at how the scan command sets up these structures:
Assistant
Perfect! Now let me check the generic language registration to understand how things are stitched together:
Assistant
Now let me look at the treesitter specs catalog to understand the pattern:
Assistant
Let me look at one example spec file to understand the structure:
Assistant
Excellent! Now let me check if there's any React/Next.js framework detection and get a summary. Let me also check one more file about how plugin structures are built:
Assistant
User
I need to understand the workflow/lifecycle transitions in desloppify. Specifically:
Is there a concept of "pre-flight" vs "execution" mode? Look for terms like preflight, pre-flight, triage, planning, execution, mode, phase transitions in the CLI and commands.
How does the next command work - does it have different modes or phases?
Look at the plan/queue lifecycle - check docs/QUEUE_LIFECYCLE.md and any related files
How does the state work in .desloppify/ - what's stored in state JSON files?
Look at how the scan → plan → next → fix cycle works
Are there any existing "hooks" or "messages" shown at transition points?
Check engine/hook_registry.py for hook patterns
Look at state.py, state_io.py for the state persistence format
Be very thorough - read the key files to understand the full lifecycle.
Assistant
I'll help you understand the workflow/lifecycle transitions in desloppify. Let me search for the relevant files and analyze the patterns.
Assistant
Let me read the key documentation and source files:
Assistant
Now let me read the state files and examine the command structure:
Assistant
Let me look at the command implementations to understand the workflow:
Assistant
Now let me look at the actual command implementations:
Assistant
Now let me read the command implementations:
Assistant
Now let me look at the plan lifecycle and state schema:
Assistant
Let me search for refresh_state more specifically:
Assistant
Excellent! Now let me look at the lifecycle phase constants:
Assistant
Perfect! Let me now read the lifecycle phase module:
Assistant
Now let me look at test files for the lifecycle to understand transitions:
Assistant
Let me check the scan preflight and postflight logic:
Assistant
Let me look at the plan reconciliation post-scan:
Assistant
Now let me search for the full lifecycle flow in state persistence and plan hooks:
Assistant
Now let me look at the state model and what's persisted:
Assistant
Perfect! Now let me look at the plan schema to understand the lifecycle state:
Assistant
Now let me check the PlanModel definition:
Assistant
Perfect! Now let me create a comprehensive summary. Let me search for a few more details about the work queue context:
Assistant
User
Find all the places in the desloppify codebase where agent-facing messages/instructions are emitted. I need to catalog every "directive" — messages shown to LLM agents to steer their behavior.
Look for:
All calls to print_user_message() — these are bordered box messages aimed at agents
The INSTRUCTIONS FOR LLM header block in agent_context.py
The transition_messages config we just added
Any other agent-steering messages (look for patterns like "IMPORTANT:", "INSTRUCTIONS", etc. in print statements)
For each one, note:
File path and line number
When it fires (post-scan, post-next, triage, transition, etc.)
Whether it's user-configurable or hardcoded
A brief description of what it tells the agent
Be thorough — check all of app/commands/
Assistant
I'll conduct a thorough search for all agent-facing messages in the desloppify codebase. Let me start by searching for the key patterns you mentioned.
Assistant
Now let me search for the key patterns:
Assistant
Good start. Now let me examine each of these files in detail:
Assistant
Now let me check the commands that use print_user_message:
Assistant
Now let me check the triage and resolve commands:
Assistant
Let me check the triage command files:
Assistant
Let me check a few more files from the triage commands:
Assistant
Now let me check for any other print_user_message in the remaining triage files and skip command:
Assistant
Let me continue reading skip.py:
Assistant
Now let me check the display dashboard file and look for any other instructions patterns:
Assistant
Let me check the stage prompts instruction blocks file:
Assistant
Perfect. Now let me create a comprehensive summary document with all my findings. Let me search for any other directive patterns I might have missed:
Assistant
Perfect! Now I have enough information. Let me compile the comprehensive summary:
Framework Detection and Plugin Architecture Summary
@dataclass
class DetectorPhase:
"""A single phase in the scan pipeline.
Each phase runs one or more detectors and returns normalized issues.
The `run` function handles both detection AND normalization (converting
raw detector output to issues with tiers/confidence).
"""
label: str
run: Callable[[Path, LangRuntimeContract], tuple[list[DetectorEntry], dict[str, int]]]
slow: bool = False
Usage Pattern: Phases are collected into LangConfig.phases list and executed sequentially in _run_phases() during scan
Execution Flow: Each phase's run() callback receives the scan path and a LangRuntimeContract interface (see below), returns issues + potentials dict
Selection: Phases can be filtered by slow flag and phase label (via is_subjective_phase() check in scan planning)
The tree-sitter framework provides a horizontal integration layer where language-agnostic detectors are defined once and reused across all supported languages.
TreeSitterLangSpec (types.py):
python
@dataclass(frozen=True)
class TreeSitterLangSpec:
"""Per-language tree-sitter configuration."""
grammar: str # TSQuery grammar name
function_query: str # TSQuery for function extraction
comment_node_types: frozenset[str] # AST node types for comments
string_node_types: frozenset[str] = frozenset() # AST node types for strings
import_query: str = "" # TSQuery for imports (optional)
resolve_import: Callable | None = None # Import path resolver (optional)
class_query: str = "" # TSQuery for classes (optional)
log_patterns: tuple[str, ...] = (...) # Regex patterns for log detection
Spec Catalog (specs/):
specs.py: Central registry mapping language names to TreeSitterLangSpec instances
compiled.py: Specs for compiled languages (Go, Rust, Java, Kotlin, C++, C#, Swift, PHP, Dart, Scala)
functional.py: Specs for functional languages (Clojure, Elixir, Erlang, F#, Haskell, OCaml, Julia)
scripting.py: Specs for scripting languages (Ruby, Bash, Lua, Perl, R, JavaScript, TypeScript, Zig, Nim, GDScript, PowerShell)
Key Pattern: A single spec definition enables duplicate detection, function extraction, import analysis, and coupling detection across any language, no custom code needed.
state_sync.py: Detects state synchronization issues
Pattern: These are conditional detectors that run within phases IF React is detected (via file content scans or manifest analysis). They're not framework-agnostic like tree-sitter phases; they're TypeScript-specific hooks that integrate into the phase pipeline.
Note: No automatic Next.js/React framework detection exists in the core. Detection is implicit via:
def setup_lang(lang, path, config, ...):
if lang.zone_rules and lang.file_finder:
files = lang.file_finder(path)
lang_run.zone_map = FileZoneMap(files, lang.zone_rules, ...)
Issue Stamping (engine/planning/scan.py line 102-120):
python
for issue in issues:
zone = lang.zone_map.get(issue.get("file", ""))
issue["zone"] = zone.value
# Apply zone policy: downgrade confidence for test zone issues, etc.
if lang_run.build_dep_graph and lang_run.dep_graph is None:
try:
lang_run.dep_graph = lang_run.build_dep_graph(path)
except (...) as exc:
log_fn(f" dep graph unavailable for review context: {exc}")
Coupling Detectors (engine/detectors/):
Access lang.dep_graph to detect cycles, single-use modules, orphaned files
Test coverage detector uses dep graph to map test file → source file
Key Access Pattern: Both are set during runtime (after LangRun creation), stored in mutable state field:
This is the full framework architecture enabling both deep language-specific plugins (TypeScript) and shallow generic plugins (any language via tool specs + optional tree-sitter).
Perfect! Now I have enough information. Let me create a comprehensive document about the workflow/lifecycle:
Workflow/Lifecycle Transitions in Desloppify
Based on my thorough analysis of the codebase, here is a detailed understanding of the workflow and lifecycle transitions:
1. Pre-Flight vs Execution Mode: The Queue Lifecycle Concept
Desloppify implements an explicit queue-based lifecycle documented in /Users/user_c042661f/Documents/desloppify/docs/QUEUE_LIFECYCLE.md:
FROZEN: # Objective work remains → show plan-start baseline
PHASE_TRANSITION: # Objective drained, subjective/workflow remain
LIVE: # Queue fully clear or no active cycle → live scores
Work progression:
desloppify next → show next item
Fix the issue
desloppify plan resolve <issue-id> → mark done
Queue updates; counts decrease
Once all objective work done → phase transition begins
Deferred disposition is part of the scan boundary, not a separate cycle phase. If deferred temporary skips exist, they block the scan step until the user reactivates or permanently dispositions them.
Checked in plan_reconcile.py:
python
if build_deferred_disposition_item(plan) is not None:
return False # Can't mark postflight complete; deferred issues block boundary
7. Queue Progress & Lifecycle Display
File: app/commands/helpers/queue_progress.py
plan_aware_queue_breakdown() returns:
python
QueueBreakdown {
queue_total: int # All items
plan_ordered: int # In prioritized queue
stale_plan_ordered: int # Stale from plan
skipped: int # Skipped
subjective: int # Subjective issues
workflow: int # Synthetic workflow items
lifecycle_phase: str # Current phase
focus_cluster: str | None # If focused
objective_actionable: int # (used for frozen/live decision)
}
score_display_mode() decision logic:
python
if plan_start_strict is None:
return LIVE # No baseline
if breakdown.lifecycle_phase == LIFECYCLE_PHASE_SCAN:
return LIVE # During scan, live scores
if breakdown.lifecycle_phase == LIFECYCLE_PHASE_EXECUTE:
return FROZEN # Active cycle, freeze baseline
if breakdown.lifecycle_phase in {REVIEW, WORKFLOW, TRIAGE}:
return PHASE_TRANSITION # Transitioning away from frozen
if breakdown.objective_actionable > 0:
return FROZEN # Objective work remains
if breakdown.queue_total > 0:
return PHASE_TRANSITION # Only subjective/workflow remain
return LIVE # Queue empty
8. State Persistence Strategy (Atomic Writes)
From multiple state I/O modules:
state: Temp write → os.replace() atomic swap
Backup: .json.bak file
Lock: none (single-process per state file)
plan: Lock-based write
Acquire plan.json.lock (fcntl.flock on Unix, msvcrt on Windows)
Read-modify-write cycle
Release lock
Backup: plan.json.bak on save
Summary: Complete Lifecycle Flow
code
1. SCAN PHASE:
- Run `desloppify scan`
- Check: queue empty? Yes → seed plan_start_scores, set lifecycle_phase = EXECUTE
- No → BLOCKED (queue has active work)
2. REVIEW PHASE (if subjective dimensions need assessment):
- Run `desloppify review --prepare`
- Agents assess dimensions
- Run `desloppify review --import <file>`
- lifecycle_phase = REVIEW_* (variants)
3. WORKFLOW PHASE:
- Synthetic items (communicate-score, create-plan) appear in queue
- User completes them
- lifecycle_phase = WORKFLOW_POSTFLIGHT
4. TRIAGE PHASE (if recommended):
- Run `desloppify plan triage --run-stages`
- Multi-stage orchestration
- Creates clusters, reorganizes queue
- lifecycle_phase = TRIAGE_POSTFLIGHT
5. EXECUTE PHASE:
- Run `desloppify next` repeatedly
- Fix issues one by one
- Run `desloppify plan resolve <id>` after each fix
- Score display: FROZEN (baseline locked)
- Phase transition: When objective drained
6. COMPLETION:
- All queue items resolved/skipped
- Plan start scores cleared
- lifecycle_phase → back to EXECUTE (no active cycle)
- Scan allowed again → cycle repeats
Key Persistence:
- plan.plan_start_scores: Frozen baseline (empty = no active cycle)
- plan.refresh_state.lifecycle_phase: Current phase
- plan.refresh_state.postflight_scan_completed_at_scan_count: Boundary marker
- state.work_items: All open/resolved issues
- state.subjective_assessments: Latest dimension scores
Excellent. Now let me compile the comprehensive catalog of all agent-facing messages I found:
Agent-Facing Messages Catalog
Based on my thorough search of the desloppify codebase, here's a complete catalog of all directives and instructions emitted to steer LLM agent behavior:
The full cascade is: scan → transition_messages → next → plan resolve/skip → triage observe/reflect/organize/enrich/sense-check → living plan execution