Skip to content

Commit a516abf

Browse files
committed
Merge branch 'main' into feature/esm-migration
2 parents 4819333 + d4b77fb commit a516abf

27 files changed

+710
-205
lines changed

.cursor/flows/ds-refactoring-flow/01-find-violations.mdc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ Step 1: Find violations
1919
Store the result in a variable called scanResult.
2020

2121
2. Perform first-level error handling:
22-
- If the function call returns an error, respond with:
22+
- If the function call returns an error or result containing "Missing ds.deprecatedCssClassesPath", respond with:
23+
<commentary>⚠️ *Cannot proceed: Missing required configuration parameter* – The `ds.deprecatedCssClassesPath` parameter must be provided when starting the MCP server to use violation detection tools. Please restart the server with this parameter configured.</commentary>
24+
Then stop execution.
25+
- If the function call returns any other error, respond with:
2326
<commentary>🚨 *Tool execution failed* – [error message]</commentary>
2427
Then stop execution.
2528
- If scanResult.totalViolations is 0, respond with:
@@ -57,7 +60,10 @@ Once the user provides a subfolder choice, proceed as follows:
5760
- Store the result in a variable called fileScan.
5861

5962
3. Perform error handling and validation:
60-
- If the function call returns an error, respond with:
63+
- If the function call returns an error containing "Missing ds.deprecatedCssClassesPath", respond with:
64+
<commentary>⚠️ *Cannot proceed: Missing required configuration parameter* – The `ds.deprecatedCssClassesPath` parameter must be provided when starting the MCP server to use violation detection tools. Please restart the server with this parameter configured.</commentary>
65+
Then stop execution.
66+
- If the function call returns any other error, respond with:
6167
<commentary>🚨 *Tool execution failed* – [error message]</commentary>
6268
Then stop execution.
6369
- If fileScan.rows.length is 0, respond with:

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ Step 1: Find violations
1717
Store the result in a variable called scanResult.
1818

1919
2. Perform first-level error handling:
20-
- If the function call returns an error, respond with:
20+
- If the function call returns an error or result containing "Missing ds.deprecatedCssClassesPath", respond with:
21+
<commentary>⚠️ *Cannot proceed: Missing required configuration parameter* – The `ds.deprecatedCssClassesPath` parameter must be provided when starting the MCP server to use violation detection tools. Please restart the server with this parameter configured.</commentary>
22+
Then stop execution.
23+
- If the function call returns any other error, respond with:
2124
<commentary>🚨 *Tool execution failed* – [error message]</commentary>
2225
Then stop execution.
2326
- If no violations are found, respond with:
@@ -54,7 +57,10 @@ Once the user provides a subfolder choice, proceed as follows:
5457
- Store the result in a variable called fileScan.
5558

5659
3. Perform error handling and validation:
57-
- If the function call returns an error, respond with:
60+
- If the function call returns an error containing "Missing ds.deprecatedCssClassesPath", respond with:
61+
<commentary>⚠️ *Cannot proceed: Missing required configuration parameter* – The `ds.deprecatedCssClassesPath` parameter must be provided when starting the MCP server to use violation detection tools. Please restart the server with this parameter configured.</commentary>
62+
Then stop execution.
63+
- If the function call returns any other error, respond with:
5864
<commentary>🚨 *Tool execution failed* – [error message]</commentary>
5965
Then stop execution.
6066
- If fileScan.rows.length is 0, respond with:

README.md

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ A Model Context Protocol (MCP) server that provides Angular project analysis and
99
- **Dependency Mapping**: Map component dependencies across modules, templates, and styles
1010
- **ESLint Integration**: Lint Angular files with automatic ESLint configuration discovery
1111
- **Project Analysis**: Analyze buildable/publishable libraries and validate import paths
12-
- **Component Documentation**: Retrieve component data and documentation
12+
- **Component Documentation**: Retrieve component data and documentation, list available components
1313

1414
## Use Cases
1515

@@ -67,6 +67,8 @@ Copy `.cursor/mcp.json.example` to the project you're working on. Copied file sh
6767
}
6868
```
6969

70+
> Note: `ds.storybookDocsRoot` and `ds.deprecatedCssClassesPath` are optional. The server will start without them. Tools that require these paths will return a clear error prompting you to provide the missing parameter.
71+
7072
> **Note**: The example file contains configuration for `ESLint` official MCP which is required for the toolkit to work properly.
7173
7274
### Configuration Parameters
@@ -76,10 +78,20 @@ Copy `.cursor/mcp.json.example` to the project you're working on. Copied file sh
7678
| Parameter | Type | Description | Example |
7779
|-----------|------|-------------|---------|
7880
| `workspaceRoot` | Absolute path | Root directory of your Angular workspace | `/Users/dev/my-angular-app` |
79-
| `ds.storybookDocsRoot` | Relative path | Root directory containing Storybook documentation | `storybook/docs` |
80-
| `ds.deprecatedCssClassesPath` | Relative path | JavaScript file mapping deprecated CSS classes | `design-system/component-options.js` |
8181
| `ds.uiRoot` | Relative path | Directory containing UI components | `packages/ui` |
8282

83+
#### Optional Parameters
84+
85+
| Parameter | Type | Description | Example |
86+
|-----------|------|-------------|---------|
87+
| `ds.storybookDocsRoot` | Relative path | Root directory containing Storybook documentation used by documentation-related tools | `storybook/docs` |
88+
| `ds.deprecatedCssClassesPath` | Relative path | JavaScript file mapping deprecated CSS classes used by violation and deprecated CSS tools | `design-system/component-options.js` |
89+
90+
When optional parameters are omitted:
91+
92+
- `ds.storybookDocsRoot`: Tools will skip Storybook documentation lookups (e.g., `get-ds-component-data` will still return implementation/import data but may have no docs files).
93+
- `ds.deprecatedCssClassesPath`: Tools that require the mapping will fail fast with a clear error. Affected tools include: `get-deprecated-css-classes`, `report-deprecated-css`, `report-all-violations`, and `report-violations`.
94+
8395
#### Deprecated CSS Classes File Format
8496

8597
The `component-options.js` file should export an array of component configurations:
@@ -135,10 +147,35 @@ my-angular-workspace/
135147

136148
### Component Analysis
137149

150+
- **`list-ds-components`**: List all available Design System components in the project with their file paths and metadata
151+
138152
- **`get-ds-component-data`**: Return data for a component including implementation files, documentation files, and import path
139153

140154
- **`build-component-usage-graph`**: Maps where given Angular components are imported (modules, specs, templates, styles) so refactors touch every file
141155

156+
### Tool behavior with optional parameters
157+
158+
The following tools work without optional params:
159+
160+
- `get-project-dependencies`
161+
- `build-component-usage-graph`
162+
- `get-ds-component-data` (documentation section is empty if `ds.storybookDocsRoot` is not set)
163+
- Component contract tools:
164+
- `build_component_contract`
165+
- `diff_component_contract`
166+
- `list_component_contracts`
167+
168+
The following tools require optional params to work:
169+
170+
- Requires `ds.deprecatedCssClassesPath`:
171+
- `get-deprecated-css-classes`
172+
- `report-deprecated-css`
173+
- `report-all-violations`
174+
- `report-violations`
175+
176+
- Requires `ds.storybookDocsRoot` for docs lookup (skipped otherwise):
177+
- `get-ds-component-data` (docs files discovery only)
178+
142179
### Component Contracts
143180

144181
- **`build_component_contract`**: Generate a static surface contract for a component's template and SCSS

docs/component-refactoring-flow.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This document describes a 3-step AI-assisted component refactoring process for i
99
2. **Refactor Component** → Execute approved checklist items and implement changes
1010
3. **Validate Component** → Verify improvements through contract comparison and scoring
1111

12-
The process includes two quality gates where human review and approval are required.
12+
The process includes two quality gates where human review and approval are required. When refactoring involves Design System components, the process can leverage selective data retrieval to access only the specific component information needed (implementation, documentation, or stories).
1313

1414
## Prerequisites
1515

@@ -155,9 +155,15 @@ At this point, all checklist items have been processed. You must review the refa
155155
### Tools used
156156

157157
- `build_component_contract` - Creates component contracts for safe refactoring
158-
- Parameters: `componentFile`, `dsComponentName` (set to "AUTO")
158+
- Parameters: `saveLocation`, `typescriptFile` (required), `templateFile` (optional), `styleFile` (optional), `dsComponentName` (optional, set to "AUTO")
159159
- Returns: contract path with component's public API, DOM structure, and styles
160160
- Purpose: Establish baseline for validation comparison
161+
- Note: Template and style files are optional for components with inline templates/styles
162+
163+
- `get-ds-component-data` - Retrieves Design System component information when needed
164+
- Parameters: `componentName`, `sections` (optional) - Array of sections to include: "implementation", "documentation", "stories", "all"
165+
- Returns: Selective component data based on refactoring needs
166+
- Purpose: Access DS component documentation and examples for proper implementation patterns
161167

162168
### Flow
163169

@@ -229,12 +235,13 @@ The rule implements a comprehensive validation process:
229235
### Tools used
230236

231237
- `build_component_contract` - Creates post-refactor component contract
232-
- Parameters: `componentFile`, `dsComponentName` (set to "AUTO")
238+
- Parameters: `saveLocation`, `typescriptFile` (required), `templateFile` (optional), `styleFile` (optional), `dsComponentName` (optional)
233239
- Returns: updated contract path with refactored component state
234240
- Purpose: Capture final component state for comparison
241+
- Note: Template and style files are optional for components with inline templates/styles
235242

236243
- `diff_component_contract` - Compares baseline and updated contracts
237-
- Parameters: `contractBeforePath`, `contractAfterPath`, `dsComponentName` (set to "AUTO")
244+
- Parameters: `saveLocation`, `contractBeforePath`, `contractAfterPath`, `dsComponentName`
238245
- Returns: detailed diff analysis showing specific changes
239246
- Purpose: Identify and analyze all modifications made during refactoring
240247

docs/contracts.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,19 @@ Because contracts track every public-facing facet of a component, any refactor t
6565
Rules taking care about the contract building during the workflow, but if you need to build it "manually" say in the chat:
6666

6767
```
68-
build_component_contract(<component-file.ts>, dsComponentName)
68+
build_component_contract(saveLocation, typescriptFile, templateFile?, styleFile?, dsComponentName?)
6969
```
7070

71-
> Replace `<component-file.ts>` with the path to your component and set `dsComponentName` to the design-system component (e.g., `DsBadge`). The tool analyses the template, TypeScript, and styles, then saves a timestamped `*.contract.json` to
72-
> `.cursor/tmp/contracts/<ds-component-kebab>/`.
71+
> Replace the parameters with:
72+
> - `saveLocation`: Path where to save the contract file (supports absolute and relative paths)
73+
> - `typescriptFile`: Path to the TypeScript component file (.ts) — **Required**
74+
> - `templateFile`: *(Optional)* Path to the component template file (.html). Omit for inline templates
75+
> - `styleFile`: *(Optional)* Path to the component style file (.scss, .css, etc.). Omit for inline styles or components without styles
76+
> - `dsComponentName`: *(Optional)* Design system component name (e.g., `DsBadge`)
77+
>
78+
> The tool analyses the template, TypeScript, and styles, then saves the contract to your specified location.
79+
>
80+
> **Note**: Angular components can have inline templates and styles. If `templateFile` or `styleFile` are not provided, the tool will extract inline template/styles from the TypeScript file.
7381
7482
## When to Build a Contract
7583

@@ -160,10 +168,13 @@ What happens when QA finds a bug or a reviewer requests changes **after** the in
160168
3. **Locate the original baseline contract** – this is the contract that was captured for the initial state (usually the very first timestamp in the folder).
161169
4. **Generate a diff** between the baseline and the latest contract:
162170
```
163-
User: diff_component_contract(<baseline>.contract.json, <latest>.contract.json, dsComponentName)
171+
User: diff_component_contract(saveLocation, contractBeforePath, contractAfterPath, dsComponentName)
164172
```
165-
The diff file will land under
166-
`.cursor/tmp/contracts/<ds-component-kebab>/diffs/`.
173+
> Replace the parameters with:
174+
> - `saveLocation`: Path where to save the diff result file (supports absolute and relative paths)
175+
> - `contractBeforePath`: Path to the baseline contract file
176+
> - `contractAfterPath`: Path to the latest contract file
177+
> - `dsComponentName`: Optional design system component name
167178
5. **Review the diff output using AI** – attach the diff and ask it to analyze it.
168179
* If only intentional changes appear, proceed to merge / re-test.
169180
* If unexpected API, DOM, or style changes surface, iterate on the fix and repeat steps 1-4.

docs/ds-refactoring-flow.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,13 @@ Before proceeding to Phase 3, you must review the comprehensive migration plan.
199199
200200
### Tools used
201201

202+
- `list-ds-components` - Lists all available Design System components in the project
203+
- Parameters: `sections` (optional) - Array of sections to include: "implementation", "documentation", "stories", "all"
204+
- Returns: Complete inventory of DS components with their file paths and metadata
205+
- Provides: Overview of available components for comprehensive migration planning
206+
202207
- `get-ds-component-data` - Retrieves comprehensive component information for all involved components
208+
- Parameters: `componentName`, `sections` (optional) - Array of sections to include: "implementation", "documentation", "stories", "all"
203209
- Returns: Complete implementation files, documentation files, import paths for multiple components
204210
- Provides: Component source code, API documentation, usage examples across scope
205211

@@ -285,7 +291,13 @@ Before proceeding to Phase 3, you must review the migration plan.
285291
286292
### Tools used
287293

294+
- `list-ds-components` - Lists all available Design System components in the project
295+
- Parameters: `sections` (optional) - Array of sections to include: "implementation", "documentation", "stories", "all"
296+
- Returns: Complete inventory of DS components with their file paths and metadata
297+
- Provides: Overview of available components for migration planning
298+
288299
- `get-ds-component-data` - Retrieves comprehensive component information
300+
- Parameters: `componentName`, `sections` (optional) - Array of sections to include: "implementation", "documentation", "stories", "all"
289301
- Returns: implementation files, documentation files, import paths
290302
- Provides: component source code, API documentation, usage examples
291303

@@ -467,9 +479,10 @@ At this point, initial refactoring is complete.
467479
### Tools used
468480

469481
- `build_component_contract` - Creates component contracts for safe refactoring
470-
- Parameters: `directory`, `templateFile`, `styleFile`, `typescriptFile`, `dsComponentName`
482+
- Parameters: `saveLocation`, `typescriptFile` (required), `templateFile` (optional), `styleFile` (optional), `dsComponentName` (optional)
471483
- Returns: contract with public API, DOM structure, styles, and metadata
472484
- Generates: JSON contract files with SHA-256 hashes for validation
485+
- Note: Template and style files are optional—extracts inline templates/styles from TypeScript when not provided
473486

474487
### Flow
475488

@@ -554,19 +567,20 @@ This is your last chance to make changes before opening the pull request.
554567
- Features: Automatic ESLint config resolution, comprehensive rule coverage
555568

556569
- `build_component_contract` - Creates contracts for refactored components
557-
- Parameters: `directory`, `templateFile`, `styleFile`, `typescriptFile`, `dsComponentName`
570+
- Parameters: `saveLocation`, `typescriptFile` (required), `templateFile` (optional), `styleFile` (optional), `dsComponentName` (optional)
558571
- Returns: JSON contract with public API, DOM structure, and styles
559572
- Purpose: Capture post-refactoring component state
573+
- Note: Template and style files are optional for components with inline templates/styles
560574

561575
- `list_component_contracts` - Lists available component contracts
562576
- Parameters: `directory`
563577
- Returns: Available contract files with timestamps and metadata
564578
- Purpose: Identify before/after contract pairs for comparison
565579

566580
- `diff_component_contract` - Compares component contracts
567-
- Parameters: `directory`, `contractBeforePath`, `contractAfterPath`, `dsComponentName`
581+
- Parameters: `saveLocation`, `contractBeforePath`, `contractAfterPath`, `dsComponentName`
568582
- Returns: Detailed diff highlighting changes in API, DOM, and styles
569-
- Saves: Diff files to `.cursor/tmp/contracts/<component>/diffs/`
583+
- Saves: Diff files to the specified saveLocation path
570584

571585
### Flow
572586

0 commit comments

Comments
 (0)