@monoes/monodesign 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/LICENSE +191 -0
  2. package/cli/bin/cli.js +83 -0
  3. package/cli/bin/commands/ignores.mjs +331 -0
  4. package/cli/engine/browser/injected/index.mjs +1938 -0
  5. package/cli/engine/cli/main.mjs +322 -0
  6. package/cli/engine/design-system.mjs +815 -0
  7. package/cli/engine/detect-antipatterns-browser.js +5246 -0
  8. package/cli/engine/detect-antipatterns.mjs +51 -0
  9. package/cli/engine/engines/browser/detect-url.mjs +278 -0
  10. package/cli/engine/engines/regex/detect-text.mjs +574 -0
  11. package/cli/engine/engines/static-html/css-cascade.mjs +1016 -0
  12. package/cli/engine/engines/static-html/detect-html.mjs +235 -0
  13. package/cli/engine/engines/visual/screenshot-contrast.mjs +190 -0
  14. package/cli/engine/findings.mjs +13 -0
  15. package/cli/engine/node/file-system.mjs +199 -0
  16. package/cli/engine/profile/profiler.mjs +167 -0
  17. package/cli/engine/registry/antipatterns.mjs +515 -0
  18. package/cli/engine/rules/checks.mjs +2704 -0
  19. package/cli/engine/shared/color.mjs +125 -0
  20. package/cli/engine/shared/constants.mjs +102 -0
  21. package/cli/engine/shared/fonts.mjs +31 -0
  22. package/cli/engine/shared/inline-ignores.mjs +149 -0
  23. package/cli/engine/shared/page.mjs +8 -0
  24. package/cli/lib/monodesign-config.mjs +641 -0
  25. package/package.json +49 -0
  26. package/skill/SKILL.src.md +277 -0
  27. package/skill/agents/monodesign-asset-producer.md +100 -0
  28. package/skill/agents/monodesign-manual-edit-applier.md +103 -0
  29. package/skill/commands/adapt.md +53 -0
  30. package/skill/commands/animate.md +65 -0
  31. package/skill/commands/audit.md +89 -0
  32. package/skill/commands/bolder.md +50 -0
  33. package/skill/commands/clarify.md +64 -0
  34. package/skill/commands/colorize.md +68 -0
  35. package/skill/commands/craft.md +51 -0
  36. package/skill/commands/critique.md +66 -0
  37. package/skill/commands/delight.md +47 -0
  38. package/skill/commands/distill.md +56 -0
  39. package/skill/commands/document.md +83 -0
  40. package/skill/commands/extract.md +74 -0
  41. package/skill/commands/harden.md +65 -0
  42. package/skill/commands/init.md +30 -0
  43. package/skill/commands/layout.md +36 -0
  44. package/skill/commands/live.md +34 -0
  45. package/skill/commands/onboard.md +50 -0
  46. package/skill/commands/optimize.md +64 -0
  47. package/skill/commands/overdrive.md +56 -0
  48. package/skill/commands/polish.md +68 -0
  49. package/skill/commands/quieter.md +57 -0
  50. package/skill/commands/shape.md +71 -0
  51. package/skill/commands/teach.md +18 -0
  52. package/skill/commands/typeset.md +59 -0
  53. package/skill/reference/adapt.md +312 -0
  54. package/skill/reference/adapt.native.md +58 -0
  55. package/skill/reference/android.md +40 -0
  56. package/skill/reference/animate.md +203 -0
  57. package/skill/reference/antipatterns-catalog.md +365 -0
  58. package/skill/reference/audit.md +135 -0
  59. package/skill/reference/audit.native.md +139 -0
  60. package/skill/reference/bolder.md +120 -0
  61. package/skill/reference/brand-workflow.md +180 -0
  62. package/skill/reference/brand.md +108 -0
  63. package/skill/reference/clarify.md +288 -0
  64. package/skill/reference/codex.md +105 -0
  65. package/skill/reference/cognitive-load.md +106 -0
  66. package/skill/reference/color-and-contrast.md +105 -0
  67. package/skill/reference/colorize.md +257 -0
  68. package/skill/reference/component-specs.md +260 -0
  69. package/skill/reference/component-states.md +274 -0
  70. package/skill/reference/component-system.md +358 -0
  71. package/skill/reference/copy-formulas.md +160 -0
  72. package/skill/reference/craft.md +123 -0
  73. package/skill/reference/critique.md +819 -0
  74. package/skill/reference/delight.md +302 -0
  75. package/skill/reference/design-principles.md +246 -0
  76. package/skill/reference/distill.md +111 -0
  77. package/skill/reference/document.md +429 -0
  78. package/skill/reference/extract.md +69 -0
  79. package/skill/reference/harden.md +347 -0
  80. package/skill/reference/heuristics-scoring.md +234 -0
  81. package/skill/reference/hooks.md +92 -0
  82. package/skill/reference/image-prompts.md +130 -0
  83. package/skill/reference/init.md +221 -0
  84. package/skill/reference/interaction-design.md +189 -0
  85. package/skill/reference/ios.md +45 -0
  86. package/skill/reference/layout.md +185 -0
  87. package/skill/reference/live.md +722 -0
  88. package/skill/reference/motion-design.md +109 -0
  89. package/skill/reference/onboard.md +234 -0
  90. package/skill/reference/optimize.md +258 -0
  91. package/skill/reference/overdrive.md +130 -0
  92. package/skill/reference/personas.md +179 -0
  93. package/skill/reference/polish.md +241 -0
  94. package/skill/reference/pre-delivery-checklist.md +108 -0
  95. package/skill/reference/product.md +60 -0
  96. package/skill/reference/quieter.md +99 -0
  97. package/skill/reference/responsive-design.md +114 -0
  98. package/skill/reference/shape.md +165 -0
  99. package/skill/reference/spatial-design.md +100 -0
  100. package/skill/reference/teach.md +10 -0
  101. package/skill/reference/token-architecture.md +222 -0
  102. package/skill/reference/typeset.md +301 -0
  103. package/skill/reference/typography.md +159 -0
  104. package/skill/reference/ux-research.md +143 -0
  105. package/skill/reference/ux-rules.md +211 -0
  106. package/skill/reference/ux-writing.md +107 -0
  107. package/skill/scripts/command-metadata.json +94 -0
  108. package/skill/scripts/context-signals.mjs +227 -0
  109. package/skill/scripts/context.mjs +1062 -0
  110. package/skill/scripts/critique-storage.mjs +243 -0
  111. package/skill/scripts/detect-csp.mjs +199 -0
  112. package/skill/scripts/detect.mjs +34 -0
  113. package/skill/scripts/hook-admin.mjs +662 -0
  114. package/skill/scripts/hook-before-edit.mjs +517 -0
  115. package/skill/scripts/hook-lib.mjs +1777 -0
  116. package/skill/scripts/hook.mjs +62 -0
  117. package/skill/scripts/lib/design-parser.mjs +843 -0
  118. package/skill/scripts/lib/is-generated.mjs +70 -0
  119. package/skill/scripts/lib/monodesign-paths.mjs +130 -0
  120. package/skill/scripts/lib/provider.mjs +5 -0
  121. package/skill/scripts/lib/target-args.mjs +43 -0
  122. package/skill/scripts/live/browser-script-parts.mjs +51 -0
  123. package/skill/scripts/live/completion.mjs +20 -0
  124. package/skill/scripts/live/event-validation.mjs +138 -0
  125. package/skill/scripts/live/insert-ui.mjs +459 -0
  126. package/skill/scripts/live/manual-apply.mjs +940 -0
  127. package/skill/scripts/live/manual-edit-routes.mjs +358 -0
  128. package/skill/scripts/live/manual-edits-buffer.mjs +153 -0
  129. package/skill/scripts/live/session-store.mjs +290 -0
  130. package/skill/scripts/live/svelte-component.mjs +827 -0
  131. package/skill/scripts/live/sveltekit-adapter.mjs +275 -0
  132. package/skill/scripts/live/ui-core.mjs +181 -0
  133. package/skill/scripts/live/vocabulary.mjs +37 -0
  134. package/skill/scripts/live-accept.mjs +813 -0
  135. package/skill/scripts/live-browser-dom.js +147 -0
  136. package/skill/scripts/live-browser-session.js +124 -0
  137. package/skill/scripts/live-browser.js +11241 -0
  138. package/skill/scripts/live-commit-manual-edits.mjs +1242 -0
  139. package/skill/scripts/live-complete.mjs +76 -0
  140. package/skill/scripts/live-copy-edit-agent.mjs +684 -0
  141. package/skill/scripts/live-discard-manual-edits.mjs +52 -0
  142. package/skill/scripts/live-inject.mjs +584 -0
  143. package/skill/scripts/live-insert.mjs +273 -0
  144. package/skill/scripts/live-manual-edit-evidence.mjs +364 -0
  145. package/skill/scripts/live-poll.mjs +385 -0
  146. package/skill/scripts/live-resume.mjs +95 -0
  147. package/skill/scripts/live-server.mjs +1138 -0
  148. package/skill/scripts/live-status.mjs +62 -0
  149. package/skill/scripts/live-target.mjs +31 -0
  150. package/skill/scripts/live-wrap.mjs +895 -0
  151. package/skill/scripts/live.mjs +298 -0
  152. package/skill/scripts/modern-screenshot.umd.js +15 -0
  153. package/skill/scripts/palette.mjs +634 -0
  154. package/skill/scripts/pin.mjs +222 -0
  155. package/src/antipatterns.ts +164 -0
  156. package/src/index.ts +13 -0
  157. package/src/rules.ts +72 -0
  158. package/src/tokens.css +116 -0
  159. package/src/tokens.ts +99 -0
package/LICENSE ADDED
@@ -0,0 +1,191 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright
52
+ owner or by an individual or Legal Entity authorized to submit on
53
+ behalf of the copyright owner. For the purposes of this definition,
54
+ "submitted" means any form of electronic, verbal, or written
55
+ communication sent to the Licensor or its representatives, including
56
+ but not limited to communication on electronic mailing lists, source
57
+ code control systems, and issue tracking systems that are managed by,
58
+ or on behalf of, the Licensor for the purpose of discussing and
59
+ improving the Work, but excluding communication that is conspicuously
60
+ marked or otherwise designated in writing by the copyright owner as
61
+ "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ Copyright 2025 Paul Bakaus
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
package/cli/bin/cli.js ADDED
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env node
2
+ // Pattern adapted from impeccable (Apache-2.0) — rebranded for monomind
3
+
4
+ /**
5
+ * Monodesign CLI
6
+ *
7
+ * Usage:
8
+ * monomind design detect [file-or-dir-or-url...]
9
+ * monomind design ignores <list|add-file|add-value|remove-...>
10
+ * monomind design --help
11
+ */
12
+
13
+ import { readFileSync, existsSync } from 'node:fs';
14
+ import { join, dirname, resolve } from 'node:path';
15
+ import { fileURLToPath } from 'node:url';
16
+
17
+ const __dirname = dirname(fileURLToPath(import.meta.url));
18
+
19
+ // Is this a detect target (the `monomind design src/` shorthand) or a mistyped
20
+ // command? Flags, URLs, path-shaped args, and real files/dirs (e.g. an
21
+ // extension-less `Dockerfile`) are targets; anything else is an unknown command.
22
+ function looksLikeDetectTarget(arg) {
23
+ const isFlag = arg.startsWith('-');
24
+ const isUrl = /^https?:\/\//i.test(arg);
25
+ const isPathShaped = arg.includes('/') || arg.includes('\\') || arg.includes('.');
26
+ const isExistingPath = existsSync(resolve(arg));
27
+ return isFlag || isUrl || isPathShaped || isExistingPath;
28
+ }
29
+
30
+ async function main() {
31
+ const args = process.argv.slice(2);
32
+ const command = args[0];
33
+
34
+ if (!command || command === '--help' || command === '-h') {
35
+ console.log(`Usage: monodesign <command> [options]
36
+
37
+ Commands:
38
+ detect [file-or-dir-or-url...] Scan for UI anti-patterns and design quality issues
39
+ ignores Manage detector ignore rules, files, and values
40
+
41
+ Options:
42
+ --help Show this help message
43
+ --version Show version number
44
+
45
+ The monodesign skill itself ships with monomind (npx monomind init).`);
46
+ process.exit(0);
47
+ }
48
+
49
+ if (command === '--version' || command === '-v') {
50
+ const pkg = JSON.parse(readFileSync(join(__dirname, '..', '..', 'package.json'), 'utf8'));
51
+ console.log(pkg.version);
52
+ process.exit(0);
53
+ }
54
+
55
+ if (command === 'detect') {
56
+ process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
57
+ const { detectCli } = await import('../engine/detect-antipatterns.mjs');
58
+ await detectCli();
59
+ } else if (command === 'ignores' || command === 'ignore') {
60
+ const { run } = await import('./commands/ignores.mjs');
61
+ await run(args.slice(1));
62
+ } else if (looksLikeDetectTarget(command)) {
63
+ // Default: treat as detect arguments (allow `monomind design src/` shorthand)
64
+ process.argv = [process.argv[0], process.argv[1], ...args];
65
+ const { detectCli } = await import('../engine/detect-antipatterns.mjs');
66
+ await detectCli();
67
+ } else {
68
+ // An unknown bareword: a mistyped command (or an old cached version run
69
+ // against newer docs). Fail loudly instead of silently statting it as a path.
70
+ console.error(`Unknown command: "${command}"\n\nTo see a list of supported commands, run:\n monodesign --help`);
71
+ process.exit(1);
72
+ }
73
+ }
74
+
75
+ main().catch(error => {
76
+ if (error?.code === 'MONODESIGN_PROMPT_ABORT') {
77
+ console.log('\nAborted.');
78
+ process.exit(130);
79
+ }
80
+
81
+ console.error(error?.message || error);
82
+ process.exit(1);
83
+ });
@@ -0,0 +1,331 @@
1
+ // Pattern adapted from impeccable (Apache-2.0) — rebranded for monomind
2
+ import path from 'node:path';
3
+
4
+ import {
5
+ getConfigPath,
6
+ getLocalConfigPath,
7
+ normalizeIgnoreValue,
8
+ readDetectionConfig,
9
+ readRawDetectionConfig,
10
+ writeDetectionConfig,
11
+ } from '../../lib/monodesign-config.mjs';
12
+
13
+ const ACTION_ALIASES = new Map([
14
+ ['status', 'list'],
15
+ ['ls', 'list'],
16
+ ['list', 'list'],
17
+ ['add-rule', 'add-rule'],
18
+ ['ignore-rule', 'add-rule'],
19
+ ['add-file', 'add-file'],
20
+ ['ignore-file', 'add-file'],
21
+ ['add-value', 'add-value'],
22
+ ['ignore-value', 'add-value'],
23
+ ['update-value', 'add-value'],
24
+ ['remove-rule', 'remove-rule'],
25
+ ['rm-rule', 'remove-rule'],
26
+ ['remove-file', 'remove-file'],
27
+ ['rm-file', 'remove-file'],
28
+ ['remove-value', 'remove-value'],
29
+ ['rm-value', 'remove-value'],
30
+ ['clear', 'clear'],
31
+ ]);
32
+
33
+ function printUsage() {
34
+ console.log(`Usage: monodesign ignores <action> [options]
35
+
36
+ Manage detector ignores in .monodesign config.
37
+
38
+ Actions:
39
+ list Show merged, shared, and local ignores
40
+ add-rule <rule> [--all-values] Ignore a rule
41
+ add-file <glob> Ignore files by glob
42
+ add-value <rule> <value> Ignore one rule/value pair
43
+ remove-rule <rule> Remove a rule ignore
44
+ remove-file <glob> Remove a file ignore
45
+ remove-value <rule> <value> Remove a rule/value ignore
46
+ clear Clear detector ignores in the selected scope
47
+
48
+ Scope:
49
+ --shared Write .monodesign/config.json (default)
50
+ --local Write .monodesign/config.local.json
51
+ --all For remove/clear, apply to shared and local
52
+
53
+ Value options:
54
+ --file <glob> Scope add-value/remove-value to a file glob
55
+ --reason <text> Store or update a reason on add-value
56
+
57
+ Examples:
58
+ monodesign ignores add-file "src/legacy/**"
59
+ monodesign ignores add-value overused-font Inter --reason "Brand font"
60
+ monodesign ignores add-value design-system-color "*" --file "src/demo.css"
61
+ monodesign ignores remove-value overused-font Inter`);
62
+ }
63
+
64
+ function parseScope(args, { allowAll = false } = {}) {
65
+ const rest = [];
66
+ let local = false;
67
+ let shared = false;
68
+ let all = false;
69
+ for (const arg of args) {
70
+ if (arg === '--local') local = true;
71
+ else if (arg === '--shared') shared = true;
72
+ else if (arg === '--all') all = true;
73
+ else rest.push(arg);
74
+ }
75
+ if ([local, shared, all].filter(Boolean).length > 1) {
76
+ throw new Error(`Pass only one scope flag: --shared${allowAll ? ', --local, or --all' : ' or --local'}`);
77
+ }
78
+ if (all && !allowAll) throw new Error('--all is only supported for remove and clear actions');
79
+ return { local, all, rest };
80
+ }
81
+
82
+ function parseValueArgs(args, { allowUnscopedWildcard = false } = {}) {
83
+ const positionals = [];
84
+ const files = [];
85
+ let reason = '';
86
+
87
+ for (let i = 0; i < args.length; i++) {
88
+ const arg = String(args[i] || '');
89
+ if (arg === '--reason') {
90
+ const chunks = [];
91
+ while (i + 1 < args.length && !String(args[i + 1]).startsWith('--')) chunks.push(args[++i]);
92
+ reason = chunks.join(' ').trim();
93
+ } else if (arg.startsWith('--reason=')) {
94
+ reason = arg.slice('--reason='.length).trim();
95
+ } else if (arg === '--file' || arg === '--files') {
96
+ if (i + 1 >= args.length) throw new Error(`${arg} requires a glob`);
97
+ files.push(String(args[++i]).trim());
98
+ } else if (arg.startsWith('--file=')) {
99
+ files.push(arg.slice('--file='.length).trim());
100
+ } else if (arg.startsWith('--files=')) {
101
+ files.push(arg.slice('--files='.length).trim());
102
+ } else if (arg.startsWith('--')) {
103
+ throw new Error(`Unknown add-value flag: ${arg}`);
104
+ } else {
105
+ positionals.push(arg);
106
+ }
107
+ }
108
+
109
+ const [rule, ...valueParts] = positionals;
110
+ const value = normalizeIgnoreValue(valueParts.join(' '));
111
+ if (!rule || !value) throw new Error('Pass a rule id and value, e.g. monodesign ignores add-value overused-font Inter');
112
+ const scopedFiles = Array.from(new Set(files.filter(Boolean)));
113
+ if (value === '*' && scopedFiles.length === 0 && !allowUnscopedWildcard) {
114
+ throw new Error('Wildcard value ignores must be scoped with --file <glob>.');
115
+ }
116
+ return {
117
+ rule: String(rule).trim().toLowerCase(),
118
+ value,
119
+ files: scopedFiles,
120
+ reason,
121
+ };
122
+ }
123
+
124
+ function formatValues(values) {
125
+ if (!values.length) return '(none)';
126
+ return values
127
+ .map((entry) => {
128
+ const fileSuffix = Array.isArray(entry.files) && entry.files.length
129
+ ? ` [${entry.files.join(', ')}]`
130
+ : '';
131
+ const reasonSuffix = entry.reason ? ` - ${entry.reason}` : '';
132
+ return `${entry.rule}=${entry.value}${fileSuffix}${reasonSuffix}`;
133
+ })
134
+ .join(', ');
135
+ }
136
+
137
+ function formatConfig(label, config) {
138
+ return [
139
+ `${label}:`,
140
+ ` ignoreRules: ${config.ignoreRules.length ? config.ignoreRules.join(', ') : '(none)'}`,
141
+ ` ignoreFiles: ${config.ignoreFiles.length ? config.ignoreFiles.join(', ') : '(none)'}`,
142
+ ` ignoreValues: ${formatValues(config.ignoreValues)}`,
143
+ ` designSystem: ${config.designSystem?.enabled === false ? 'disabled' : 'enabled'}`,
144
+ ].join('\n');
145
+ }
146
+
147
+ function list(cwd) {
148
+ const merged = readDetectionConfig(cwd);
149
+ const shared = readRawDetectionConfig(cwd);
150
+ const local = readRawDetectionConfig(cwd, { local: true });
151
+ return [
152
+ 'Monodesign detector ignores',
153
+ ` shared file: ${path.relative(cwd, getConfigPath(cwd)) || getConfigPath(cwd)}`,
154
+ ` local file: ${path.relative(cwd, getLocalConfigPath(cwd)) || getLocalConfigPath(cwd)}`,
155
+ '',
156
+ formatConfig('Merged', merged),
157
+ '',
158
+ formatConfig('Shared', shared),
159
+ '',
160
+ formatConfig('Local', local),
161
+ ].join('\n');
162
+ }
163
+
164
+ function readScopeConfig(cwd, local) {
165
+ return readRawDetectionConfig(cwd, { local });
166
+ }
167
+
168
+ function writeScopeConfig(cwd, config, local) {
169
+ return writeDetectionConfig(cwd, config, { local });
170
+ }
171
+
172
+ function parseRuleArgs(args) {
173
+ const positionals = [];
174
+ let allValues = false;
175
+
176
+ for (let i = 0; i < args.length; i++) {
177
+ const arg = String(args[i] || '');
178
+ if (arg === '--all-values') {
179
+ allValues = true;
180
+ } else if (arg === '--reason') {
181
+ while (i + 1 < args.length && !String(args[i + 1]).startsWith('--')) i++;
182
+ } else if (arg.startsWith('--reason=')) {
183
+ // Accepted for symmetry with add-value; ignoreRules stores ids only.
184
+ } else if (arg.startsWith('--')) {
185
+ throw new Error(`Unknown add-rule flag: ${arg}`);
186
+ } else {
187
+ positionals.push(arg);
188
+ }
189
+ }
190
+
191
+ return {
192
+ rule: String(positionals[0] || '').trim().toLowerCase(),
193
+ allValues,
194
+ };
195
+ }
196
+
197
+ function addRule(cwd, args) {
198
+ const { local, rest } = parseScope(args);
199
+ const { rule, allValues } = parseRuleArgs(rest);
200
+ if (!rule) throw new Error('Pass a rule id, e.g. monodesign ignores add-rule side-tab');
201
+ if (rule === 'overused-font' && !allValues) {
202
+ throw new Error('overused-font is value-specific by default. Use add-value overused-font <font>, or add-rule overused-font --all-values for broad suppression.');
203
+ }
204
+ const config = readScopeConfig(cwd, local);
205
+ if (!config.ignoreRules.includes(rule)) config.ignoreRules.push(rule);
206
+ const target = writeScopeConfig(cwd, config, local);
207
+ return `Added ${rule} to ${local ? 'local' : 'shared'} detector ignoreRules (${path.relative(cwd, target) || target}).`;
208
+ }
209
+
210
+ function addFile(cwd, args) {
211
+ const { local, rest } = parseScope(args);
212
+ const glob = String(rest[0] || '').trim();
213
+ if (!glob) throw new Error('Pass a glob, e.g. monodesign ignores add-file "src/legacy/**"');
214
+ const config = readScopeConfig(cwd, local);
215
+ if (!config.ignoreFiles.includes(glob)) config.ignoreFiles.push(glob);
216
+ const target = writeScopeConfig(cwd, config, local);
217
+ return `Added ${glob} to ${local ? 'local' : 'shared'} detector ignoreFiles (${path.relative(cwd, target) || target}).`;
218
+ }
219
+
220
+ function addValue(cwd, args) {
221
+ const { local, rest } = parseScope(args);
222
+ const parsed = parseValueArgs(rest);
223
+ const config = readScopeConfig(cwd, local);
224
+ const key = ignoreValueKey(parsed);
225
+ const existing = config.ignoreValues.find((entry) => ignoreValueKey(entry) === key);
226
+ if (existing) {
227
+ if (parsed.reason) existing.reason = parsed.reason;
228
+ if (parsed.files.length) existing.files = parsed.files;
229
+ } else {
230
+ const entry = {
231
+ rule: parsed.rule,
232
+ value: parsed.value,
233
+ createdAt: new Date().toISOString(),
234
+ };
235
+ if (parsed.files.length) entry.files = parsed.files;
236
+ if (parsed.reason) entry.reason = parsed.reason;
237
+ config.ignoreValues.push(entry);
238
+ }
239
+ const target = writeScopeConfig(cwd, config, local);
240
+ return `Added ${parsed.rule}=${parsed.value} to ${local ? 'local' : 'shared'} detector ignoreValues (${path.relative(cwd, target) || target}).`;
241
+ }
242
+
243
+ function removeFromScopes(cwd, args, remover) {
244
+ const { local, all, rest } = parseScope(args, { allowAll: true });
245
+ const scopes = all ? [false, true] : [local];
246
+ const removed = [];
247
+ for (const isLocal of scopes) {
248
+ const config = readScopeConfig(cwd, isLocal);
249
+ const count = remover(config, rest);
250
+ if (count > 0) {
251
+ const target = writeScopeConfig(cwd, config, isLocal);
252
+ removed.push(`${count} from ${isLocal ? 'local' : 'shared'} (${path.relative(cwd, target) || target})`);
253
+ }
254
+ }
255
+ return removed.length ? `Removed ${removed.join(', ')}.` : 'No matching detector ignore found.';
256
+ }
257
+
258
+ function removeRule(cwd, args) {
259
+ return removeFromScopes(cwd, args, (config, rest) => {
260
+ const rule = String(rest[0] || '').trim().toLowerCase();
261
+ if (!rule) throw new Error('Pass a rule id, e.g. monodesign ignores remove-rule side-tab');
262
+ const before = config.ignoreRules.length;
263
+ config.ignoreRules = config.ignoreRules.filter((entry) => entry !== rule);
264
+ return before - config.ignoreRules.length;
265
+ });
266
+ }
267
+
268
+ function removeFile(cwd, args) {
269
+ return removeFromScopes(cwd, args, (config, rest) => {
270
+ const glob = String(rest[0] || '').trim();
271
+ if (!glob) throw new Error('Pass a glob, e.g. monodesign ignores remove-file "src/legacy/**"');
272
+ const before = config.ignoreFiles.length;
273
+ config.ignoreFiles = config.ignoreFiles.filter((entry) => entry !== glob);
274
+ return before - config.ignoreFiles.length;
275
+ });
276
+ }
277
+
278
+ function removeValue(cwd, args) {
279
+ return removeFromScopes(cwd, args, (config, rest) => {
280
+ const parsed = parseValueArgs(rest, { allowUnscopedWildcard: true });
281
+ const key = ignoreValueKey(parsed);
282
+ const before = config.ignoreValues.length;
283
+ config.ignoreValues = config.ignoreValues.filter((entry) => ignoreValueKey(entry) !== key);
284
+ return before - config.ignoreValues.length;
285
+ });
286
+ }
287
+
288
+ function clear(cwd, args) {
289
+ const { local, all, rest } = parseScope(args, { allowAll: true });
290
+ if (rest.length > 0) throw new Error('clear does not take positional arguments');
291
+ const scopes = all ? [false, true] : [local];
292
+ for (const isLocal of scopes) {
293
+ const config = readScopeConfig(cwd, isLocal);
294
+ config.ignoreRules = [];
295
+ config.ignoreFiles = [];
296
+ config.ignoreValues = [];
297
+ writeScopeConfig(cwd, config, isLocal);
298
+ }
299
+ return `Cleared detector ignores in ${all ? 'shared and local config' : local ? 'local config' : 'shared config'}.`;
300
+ }
301
+
302
+ function ignoreValueKey(entry) {
303
+ const files = Array.isArray(entry.files) && entry.files.length ? entry.files.join('\x1f') : '';
304
+ return `${String(entry.rule || '').trim().toLowerCase()}\0${normalizeIgnoreValue(entry.value)}\0${files}`;
305
+ }
306
+
307
+ export async function run(args = [], opts = {}) {
308
+ const cwd = opts.cwd || process.cwd();
309
+ const actionArg = args[0] || 'list';
310
+ if (actionArg === '--help' || actionArg === '-h') {
311
+ printUsage();
312
+ return;
313
+ }
314
+ const action = ACTION_ALIASES.get(String(actionArg).toLowerCase());
315
+ if (!action) {
316
+ throw new Error(`Unknown ignores action: ${actionArg}. Run "monodesign ignores --help".`);
317
+ }
318
+ const rest = args.slice(1);
319
+ let out;
320
+ switch (action) {
321
+ case 'list': out = list(cwd); break;
322
+ case 'add-rule': out = addRule(cwd, rest); break;
323
+ case 'add-file': out = addFile(cwd, rest); break;
324
+ case 'add-value': out = addValue(cwd, rest); break;
325
+ case 'remove-rule': out = removeRule(cwd, rest); break;
326
+ case 'remove-file': out = removeFile(cwd, rest); break;
327
+ case 'remove-value': out = removeValue(cwd, rest); break;
328
+ case 'clear': out = clear(cwd, rest); break;
329
+ }
330
+ if (out) console.log(out);
331
+ }