feat: add report-audit-token-usage MCP tool#30
Merged
Karnaukhov-kh merged 5 commits intomainfrom Apr 20, 2026
Merged
Conversation
added 3 commits
April 14, 2026 13:32
report-audit-token-usage MCP toolreport-audit-token-usage MCP tool
There was a problem hiding this comment.
Pull request overview
Adds a new MCP tool (report-audit-token-usage) to audit design token health in consumer style files, supporting both token reference validation (typo detection + suggestions) and token override detection (including mechanism/classification reporting).
Changes:
- Introduces
report-audit-token-usagetool (schema, handler, validate/overrides pipelines, formatter, persistence) plus comprehensive Vitest coverage. - Extends token infrastructure to support multiple
ds.tokens.filePatternglob patterns and improves glob-to-regex conversion (brace expansion + tests). - Updates styles AST parsing to expose
decl.importantasScssPropertyEntry.important, and updates docs/config wiring accordingly.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/shared/utils/src/lib/file/glob-utils.ts | Adds brace-expansion support to globToRegex via sentinel extraction/restoration. |
| packages/shared/utils/src/lib/file/glob-utils.spec.ts | Adds unit tests for glob-to-regex behavior including brace expansion and escaping regressions. |
| packages/shared/styles-ast-utils/src/lib/scss-value-parser.ts | Extends ScssPropertyEntry with important: boolean sourced from PostCSS decl.important. |
| packages/angular-mcp/src/main.ts | Updates CLI option parsing to allow ds.tokens.filePattern to be provided multiple times (array). |
| packages/angular-mcp-server/tsconfig.lib.json | Adjusts project references (ordering + adds typescript-ast-utils reference). |
| packages/angular-mcp-server/tsconfig.json | Adjusts project references (ordering + adds typescript-ast-utils reference). |
| packages/angular-mcp-server/src/lib/validation/angular-mcp-server-options.schema.ts | Updates TokensConfigSchema.filePattern to accept `string |
| packages/angular-mcp-server/src/lib/tools/ds/tools.ts | Registers the new audit-token-usage tool in DS tool list. |
| packages/angular-mcp-server/src/lib/tools/ds/shared/utils/token-dataset-loader.ts | Updates token file discovery to accept multiple file patterns and improves “no files matched” messaging. |
| packages/angular-mcp-server/src/lib/tools/ds/audit-token-usage/utils/validate-mode.ts | Implements validate pipeline: var() extraction, prefix matching, dataset lookup, Levenshtein suggestions, optional brand warnings. |
| packages/angular-mcp-server/src/lib/tools/ds/audit-token-usage/utils/spec/validate-mode.spec.ts | Adds unit tests for validate-mode helpers/behavior. |
| packages/angular-mcp-server/src/lib/tools/ds/audit-token-usage/utils/spec/overrides-mode.spec.ts | Adds tests for override mechanism detection/classification + pipeline behavior including !important. |
| packages/angular-mcp-server/src/lib/tools/ds/audit-token-usage/utils/spec/edit-distance.spec.ts | Adds correctness tests for Levenshtein implementation. |
| packages/angular-mcp-server/src/lib/tools/ds/audit-token-usage/utils/overrides-mode.ts | Implements overrides pipeline: declaration overrides + !important consumption detection, plus counts. |
| packages/angular-mcp-server/src/lib/tools/ds/audit-token-usage/utils/override-classifier.ts | Adds mechanism detection + intent classification logic. |
| packages/angular-mcp-server/src/lib/tools/ds/audit-token-usage/utils/edit-distance.ts | Adds Levenshtein distance implementation (Wagner–Fischer). |
| packages/angular-mcp-server/src/lib/tools/ds/audit-token-usage/spec/graceful-degradation.spec.ts | Adds tests for degraded operation when config/dataset is missing or empty. |
| packages/angular-mcp-server/src/lib/tools/ds/audit-token-usage/spec/audit-token-usage.tool.spec.ts | Adds tool-level tests for active mode resolution, summary correctness, formatting/output structure. |
| packages/angular-mcp-server/src/lib/tools/ds/audit-token-usage/models/types.ts | Defines input/options and output result types for the tool. |
| packages/angular-mcp-server/src/lib/tools/ds/audit-token-usage/models/schema.ts | Defines the MCP tool schema for report-audit-token-usage. |
| packages/angular-mcp-server/src/lib/tools/ds/audit-token-usage/index.ts | Public exports for the new tool module. |
| packages/angular-mcp-server/src/lib/tools/ds/audit-token-usage/audit-token-usage.tool.ts | Main handler, summary builder, prefix derivation, exclude filtering, persistence, and pretty formatting. |
| docs/tools.md | Documents the new MCP tool usage and parameters. |
| docs/architecture-internal-design.md | Clarifies propertyPrefix behavior in relation to the new tool. |
| .nvmrc | Updates the pinned Node version. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
AdrianRomanski
requested changes
Apr 20, 2026
AdrianRomanski
approved these changes
Apr 20, 2026
rapczynska
approved these changes
Apr 20, 2026
Karnaukhov-kh
approved these changes
Apr 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New tool for auditing design token health in consumer style files. Two modes — validate (typo detection with suggestions) and overrides (token re-declaration detection).
Validate mode
var()references against the loaded token dataset--semantic-,--ds-, etc.) from the dataset automatically whenpropertyPrefixis nullOverrides mode
:host,::ng-deep, class selectors,:root[data-theme]!importanton token-consuming declarationslegitimate,component-override,deep-override,important-override,inline-override,scope-violationSupporting changes
styles-ast-utils:ScssPropertyEntrynow exposesimportant: booleanfrom PostCSS (PostCSS strips!importantfromdecl.valueintodecl.important)glob-utils: new tests for glob-to-regex conversiontoken-dataset-loader: minor adjustments for token loadingtools.md, clarifiedpropertyPrefixbehaviour inarchitecture-internal-design.mdFiles added
audit-token-usage.tool.tsmodels/schema.tsmodels/types.tsutils/validate-mode.tsutils/overrides-mode.tsutils/override-classifier.tsutils/edit-distance.tsindex.tsTest coverage
audit-token-usage.tool.spec.ts— output structure, summary counts, formattergraceful-degradation.spec.ts— missing config, empty dataset, detection-only modeedit-distance.spec.ts— identity, symmetry, empty string, known distancesoverrides-mode.spec.ts— mechanism detection, classification,runOverridesModepipelinevalidate-mode.spec.ts— prefix filtering, suggestion threshold, invalid token report fields