You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Discovering URL(s) where given component(s) can be found
3
+
globs:
4
+
alwaysApply: false
5
+
---
6
+
{
7
+
"schema_version": "1.0",
8
+
"task": "Angular routing analysis and URL discovery",
9
+
"description": "Analyze Angular routing hierarchy using bottom-up approach: identify complete routing structure from app_directory (top point) and parent routes for specific files (bottom point), then connect them bottom-up with comprehensive redirect resolution. Output plain text with markdown syntax throughout; at the end, persist discovered URLs to JSON files as specified.",
10
+
"inputs": {
11
+
"app_directory": "Directory path where route definition files should be scanned (e.g., 'src/app')",
12
+
"files": "Array of specific file paths to analyze (e.g., ['src/app/components/user.component.ts'])"
"response_format": "plain text with markdown syntax wrapped with <routing_discovery> tags, maximum 200 tokens, NO file generation",
20
+
"steps": [
21
+
"TOP POINT DISCOVERY: Scan app_directory completely to identify ALL routing files and build complete routing hierarchy tree (app.routes.ts, app-routing.module.ts, main.ts, and all loadChildren declarations).",
22
+
"BOTTOM-UP DUAL DISCOVERY: For each file in 'files' parameter, extract component class name AND template selector. From these specific components, search upward for BOTH: (1) Direct parent routes referencing the component class, (2) Parent components using the template selector. MANDATORY: Trace ALL upward paths from each specific component - do not stop after finding first parent.",
23
+
"BOTTOM-UP ROUTE MAPPING: From each specific component file, map ALL discovered upward paths. A single component may have multiple parent relationships (direct route definitions + template selector usage). Document every upward path discovered from the bottom point.",
24
+
"ENHANCED CLASSIFICATION: Classify each component as DIRECTLY-ROUTABLE (found in route definitions), INDIRECTLY-ROUTABLE (template selector usage only), or BOTH. Components can have multiple routing scenarios simultaneously.",
25
+
"VALIDATION: Present 'Files to Analyze', 'TOP POINT: Complete App Routing Hierarchy', 'BOTTOM POINT: All Route Scenarios per File', and 'ROUTE COMPLETENESS CHECK' confirming exhaustive search was performed."
26
+
]
27
+
},
28
+
{
29
+
"id": 2,
30
+
"name": "Non-Routable Component Analysis",
31
+
"requires_approval": false,
32
+
"response_format": "plain text with markdown syntax wrapped with <non_routable_analysis> tags, maximum 200 tokens, NO file generation",
33
+
"steps": [
34
+
"IDENTIFY NON-ROUTABLE COMPONENTS: From the files list, identify components without direct route definitions (modals, dialogs, library components, child components).",
35
+
"ROUTABLE PARENT DISCOVERY: For non-routable components, traverse the component hierarchy upward through multiple levels to find the first routable parent component. Handle multi-level chains where non-routable components are nested within other non-routable components.",
36
+
"MODAL/LIBRARY TRIGGER ANALYSIS: For modal and library components, identify the parent component where they are used, triggered, or instantiated (MatDialog.open, component selectors, service calls).",
37
+
"USAGE RELATIONSHIP MAPPING: Document the complete relationship chain including all intermediate levels: Non-routable Component → Intermediate Parent(s) → Final Routable Parent → Route Path. Show the full traversal path for multi-level hierarchies.",
38
+
"NON-ROUTABLE VALIDATION: Confirm all non-routable components have identified parent relationships before proceeding to route construction."
39
+
]
40
+
},
41
+
{
42
+
"id": 3,
43
+
"name": "Exhaustive Route Construction & Verification",
44
+
"requires_approval": false,
45
+
"response_format": "plain text with markdown syntax wrapped with <bottom_up_connection> tags, maximum 200 tokens, NO file generation",
46
+
"steps": [
47
+
"COMPREHENSIVE REDIRECT MAPPING: Scan ALL routing files in the complete hierarchy for 'redirectTo' declarations. Create redirect mapping table with [original_path] → [redirectTo_path], including application-level, legacy, and inter-module redirects. Check for conflicting redirects and redirect loops.",
48
+
"BOTTOM-UP EXHAUSTIVE TRACING: For each component from Phase 1, trace ALL upward paths to build complete route chains: (1) Direct bottom-up routes from component class to routing hierarchy, (2) Indirect bottom-up routes from template selector through parent components to routing hierarchy. Cross-reference both upward traces to ensure no paths are missed.",
49
+
"MULTI-SCENARIO PATH CONSTRUCTION: Build complete paths for every routing scenario discovered. Apply redirect resolution at each level. Document all paths: direct routes, redirected routes, and parent-access routes for non-routable components.",
50
+
"ROUTE COMPLETENESS VERIFICATION: Cross-check that all component routing scenarios from Phase 1 have corresponding path constructions. Verify no discovered routes were omitted from path building.",
51
+
"MANDATORY PHASE 3 EXAMPLES: Provide 1-3 concrete route examples per routing scenario (not just per file). If component has both direct and indirect routes, show examples for BOTH. Include realistic culture codes and parameters."
52
+
]
53
+
},
54
+
{
55
+
"id": 4,
56
+
"name": "Parameter & Visibility Analysis",
57
+
"requires_approval": false,
58
+
"response_format": "plain text with markdown syntax wrapped with <parameter_analysis> tags, maximum 200 tokens, NO file generation",
59
+
"steps": [
60
+
"Extract parameter constraints from TypeScript files using ALL established routing connections from Phase 3.",
61
+
"Scan for visibility conditions: @if, *ngIf directives, route guards, resolvers, route data, permissions, and feature flags along ALL discovered route paths.",
62
+
"HUMAN-FRIENDLY VISIBILITY SUMMARY: Produce a concise developer-friendly object with keys such as: 'authorization' ('required' | 'not required'), 'guards' (array of guard class names), 'resolvers' (string like 'A or B' when multiple), 'redirectBehavior' (e.g., '/old redirects to /new'), 'featureFlags' (array), 'conditions' (bullet-like phrases distilled from *ngIf/@if and route data), and optional 'notes'. Normalize common patterns (e.g., allowAnonymous: true → authorization: 'not required'). Include inherited conditions across the bottom-up chain.",
63
+
"Provide realistic examples with different culture codes and parameter values for ALL traced paths (direct and indirect).",
64
+
"Validate that all routing scenarios maintain parameter inheritance and visibility constraints across different access methods."
"response_format": "plain text with markdown syntax wrapped with <quick_access_summary> tags",
72
+
"steps": [
73
+
"COLLECT ALL SCENARIOS: Gather route examples from Phase 3 for EVERY routing scenario discovered. Include both direct routes and parent-access routes. MANDATORY: Every component must have at least one URL example for each routing scenario identified.",
74
+
"GENERATE SUMMARY STRUCTURE: Create '🎯 QUICK ACCESS SUMMARY' section with exact format: Header 'Files Analyzed: [List all files]' followed by subsections '## File: [Filename.extension]' for each file.",
75
+
"FORMAT VALIDATION: Use MANDATORY bullet list format with markdown bullets (-) for route examples. CRITICAL: Each route example MUST start with '- /' (markdown bullet + forward slash). FORBIDDEN: NO tables, NO pipes (|), NO table formatting whatsoever.",
76
+
"COMPLETE SCENARIO COVERAGE: Include ALL discovered routing scenarios: direct routes, redirected routes, and parent-access routes. Add clear notation: '(direct route)', '(redirects to X)', '(non-routable, found in parent component at URL)'. MANDATORY: Cover every routing scenario from Phase 1 discovery.",
77
+
"FINAL VERIFICATION AND PERSISTENCE (MANDATORY): Confirm the summary contains ALL files AND ALL routing scenarios. Then, for each analyzed component, WRITE a JSON file at `.cursor/tmp/discovered-urls/{{component-name}}.json` with schema: { \"component\": { \"urls\": [from summary], \"visibilityConditions\": <human-friendly object from Phase 4, or an array of such objects when scenarios differ> } }. Use the component TypeScript class name when available for {{component-name}}, otherwise the component file basename without extensions. Create the target directory if it does not exist and overwrite existing files."
Copy file name to clipboardExpand all lines: docs/ds-refactoring-flow.md
+118Lines changed: 118 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -598,3 +598,121 @@ While this rule operates independently, it can inform the main refactoring flow:
598
598
### Preferred model
599
599
600
600
Claude-4-Sonnet
601
+
602
+
603
+
## discover-affected-urls.mdc (Independent Step)
604
+
605
+
### Goal
606
+
607
+
Analyze Angular routing hierarchy to discover URL(s) where specific component files can be accessed in a web application. This rule performs comprehensive routing analysis using a bottom-up approach to identify both directly routable components and non-routable components (modals, dialogs, child components) that are accessible through their parent routes, providing complete URL discovery with redirect resolution.
608
+
609
+
### Process
610
+
611
+
To start this process, drag file `discover-affected-urls.mdc` to the cursor chat and provide the required parameters:
0 commit comments