Skip to content

Commit f32cd79

Browse files
poltorakSzymon.Poltorak
andauthored
feat(): report all violations (#13)
* feat(): report all violations * feat(): fix code style and tool description * feat(): update tool docs * feat(): don't show duplicated violations * chore(): add tool / prompt testing component * feat(): update cursor rules and ds-refactoring-flow * refactor(): clean up cursor files * docs(): extend docs with alternative flow * refactor(): update names for consistency --------- Co-authored-by: Szymon.Poltorak <[email protected]>
1 parent 7fcd5d6 commit f32cd79

23 files changed

+1013
-563
lines changed

.cursor/flows/README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,34 @@ Flows are collections of rule files (.mdc) that guide the AI through multi-step
2727
**Location:** `ds-refactoring-flow/`
2828
**Purpose:** Migrate components from deprecated design system patterns to modern alternatives
2929

30-
**Files:**
31-
- `01-find-violations.mdc` - Identify deprecated component usage
32-
- `02-plan-refactoring.mdc` - Create detailed migration strategy
30+
**Flow Options:**
31+
32+
**Option A: Targeted Approach** (recommended for focused, incremental migrations)
33+
- `01-find-violations.mdc` - Identify specific deprecated component usage
34+
- `02-plan-refactoring.mdc` - Create detailed migration strategy for specific cases
35+
36+
**Option B: Comprehensive Approach** (recommended for large-scale migrations)
37+
- `01b-find-all-violations.mdc` - Scan entire codebase, group by folders, select subfolder for detailed analysis
38+
- `02b-plan-refactoring-for-all-violations.mdc` - Create comprehensive migration plan for all violations in scope
39+
40+
**Continuation Steps** (used with both approaches):
3341
- `03-non-viable-cases.mdc` - Handle non-migratable components by marking them for exclusion
3442
- `03-fix-violations.mdc` - Execute code changes
3543
- `04-validate-changes.mdc` - Verify improvements through contract comparison
3644
- `05-prepare-report.mdc` - Generate testing checklists and documentation
3745
- `clean-global-styles.mdc` - Independent analysis of deprecated CSS usage
3846

47+
**Choosing Your Approach:**
48+
- **Targeted (01 → 02)**: Use when working on specific components or small sets of violations. Provides focused analysis and incremental progress.
49+
- **Comprehensive (01b → 02b)**: Use when planning large-scale migrations across multiple folders. Provides broad overview first, then detailed planning for selected scope.
50+
3951
**Special Handling:**
4052
- **Non-Viable Cases**: When components are identified as non-viable during the planning step, use `03-non-viable-cases.mdc` instead of proceeding with the normal fix violations step. This marks components with special prefixes (`after-migration-[ORIGINAL_CLASS]`) to exclude them from future violation reports.
4153

4254
**Use Cases:**
43-
- **Primary Flow**: Migrating components to modern design system patterns
44-
- **Non-Viable Handling**: Alternative handling within the main flow for legacy components that cannot be migrated
55+
- **Targeted Flow**: Incremental migration of specific components or small violation sets
56+
- **Comprehensive Flow**: Large-scale migration planning across multiple directories
57+
- **Non-Viable Handling**: Alternative handling within either flow for legacy components that cannot be migrated
4558

4659
## How to Use Flows
4760

.cursor/rules/01-find-violations.mdc renamed to .cursor/flows/ds-refactoring-flow/01b-find-all-violations.mdc

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ alwaysApply: false
66
You are an AI assistant tasked with helping a developer identify and plan refactoring for legacy component usage. Follow these instructions carefully to complete the task in two main steps.
77

88
First, I will provide you with the following information:
9-
<component_name>{{COMPONENT_NAME}}</component_name>
109
<directory>{{DIRECTORY}}</directory>
1110

1211
Step 1: Find violations
1312

14-
1. Run a scan using the report-violations function with the following parameters:
15-
- component: {{COMPONENT_NAME}}
13+
1. Run a scan using the report-all-violations function with the following parameters:
1614
- directory: {{DIRECTORY}}
1715
- groupBy: "folder"
1816

@@ -22,8 +20,8 @@ Step 1: Find violations
2220
- If the function call returns an error, respond with:
2321
<commentary>🚨 *Tool execution failed* – [error message]</commentary>
2422
Then stop execution.
25-
- If scanResult.totalViolations is 0, respond with:
26-
"✅ No legacy usage of {{COMPONENT_NAME}} found."
23+
- If no violations are found, respond with:
24+
"✅ No legacy usage found."
2725
Then stop execution.
2826
- Otherwise, continue to the next step.
2927

@@ -50,8 +48,7 @@ Once the user provides a subfolder choice, proceed as follows:
5048
Then stop execution.
5149

5250
2. Run a file-level scan:
53-
- Use the report-violations function with these parameters:
54-
- component: {{COMPONENT_NAME}}
51+
- Use the report-all-violations function with these parameters:
5552
- directory: {{SUBFOLDER}}
5653
- groupBy: "file"
5754
- Store the result in a variable called fileScan.
@@ -73,12 +70,4 @@ Once the user provides a subfolder choice, proceed as follows:
7370
...
7471
</violations>
7572
- After the </violations> tag, prompt the user with:
76-
❓ **Please attach the "Plan Phase" rules now so I can start refactoring planning.**
77-
78-
As in Step 1, any side remarks should go in an optional <commentary>...</commentary> tag.
79-
80-
Final instructions:
81-
- Always use the exact format and wording provided for outputs and prompts.
82-
- Do not add any explanations or additional text unless explicitly instructed.
83-
- If you encounter any situations not covered by these instructions, respond with:
84-
<commentary>⚠️ Unexpected situation encountered. Please provide further guidance.</commentary>
73+
❓ **Please attach the "Plan Phase" rules now so I can start refactoring planning.**
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
description:
3+
globs:
4+
alwaysApply: false
5+
---
6+
You are an AI assistant tasked with helping a development team migrate legacy components to a new design system. Your goal is to analyze the current codebase, identify areas that need updating, and provide a detailed plan for the migration process. This task will be completed in three phases: a comprehensive analysis, a detailed plan creation, and a checklist creation.
7+
8+
You will be working with the following inputs:
9+
<folder_path>{{FOLDER_PATH}}</folder_path>: The path to the folder containing the legacy components
10+
<component_docs>{{COMPONENT_DOCS}}</component_docs>: The official documentation for the target design-system components
11+
<component_code>{{COMPONENT_CODE}}</component_code>: The source files of the target design-system components
12+
<usage_graph>{{USAGE_GRAPH}}</usage_graph>: A graph showing the usage of the legacy components in the specified folder
13+
<library_data>{{LIBRARY_DATA}}</library_data>: Information about library type
14+
15+
# Phase 1: Comprehensive Analysis
16+
17+
1. Review all provided inputs: COMPONENT_DOCS, COMPONENT_CODE, USAGE_GRAPH, and LIBRARY_DATA.
18+
19+
2. Analyze the current codebase, focusing on:
20+
a. The approved markup and API for the target components
21+
b. The actual implementation of the design-system components
22+
c. All files (templates, TS, styles, specs, NgModules) that reference the legacy components
23+
d. Dependencies and library information
24+
25+
3. Create a comprehensive summary of the analysis, including:
26+
a. Total number of files affected
27+
b. Assessment of migration complexity (Low, Medium, High)
28+
c. Any potential non-viable migrations that may require manual rethinking
29+
d. Key decisions or assumptions made during the analysis
30+
e. Insights gained from examining the component files
31+
f. Implications of the LIBRARY_DATA on the migration process
32+
33+
Write your comprehensive analysis in <comprehensive_analysis> tags.
34+
35+
# Phase 2: Detailed Plan Creation
36+
37+
Please think about this problem thoroughly

.cursor/rules/02-plan-refactoring.mdc

Lines changed: 0 additions & 81 deletions
This file was deleted.

.cursor/rules/03-fix-violations.mdc

Lines changed: 0 additions & 49 deletions
This file was deleted.

.cursor/rules/03-non-viable-cases.mdc

Lines changed: 0 additions & 100 deletions
This file was deleted.

0 commit comments

Comments
 (0)