@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
@@ -0,0 +1,227 @@
1
+ #!/usr/bin/env node
2
+ // Pattern adapted from impeccable (Apache-2.0) — rebranded for monomind
3
+ /**
4
+ * Context-signals gatherer for the bare Monodesign invocation
5
+ * (no-argument) path. Collects cheap, deterministic signals about the current
6
+ * project and emits them as JSON.
7
+ *
8
+ * It does NOT score or rank. The agent reasons over the raw signals using its
9
+ * knowledge of the command catalog (see SKILL.md routing rule 1). Deliberately
10
+ * light: no LLM calls, no detector run (`monomind design detect` is heavier and
11
+ * opt-in), no file writes. Every probe is best-effort and never throws; the
12
+ * output is always valid JSON.
13
+ *
14
+ * Signals:
15
+ * - setup: PRODUCT.md / DESIGN.md presence, register, whether code exists
16
+ * - critique: the latest cached critique score (.monodesign/critique)
17
+ * - git: branch + files changed vs the default branch (a scope hint)
18
+ * - devServer: whether a local dev server answers on a common port (gates live)
19
+ */
20
+ import fs from 'node:fs';
21
+ import net from 'node:net';
22
+ import path from 'node:path';
23
+ import { fileURLToPath } from 'node:url';
24
+ import { execFileSync } from 'node:child_process';
25
+ import { loadContext, extractRegister, extractPlatform } from './context.mjs';
26
+ import { getCritiqueDir } from './lib/monodesign-paths.mjs';
27
+
28
+ /** Is there code here at all, or just context files / an empty repo? */
29
+ function hasCode(cwd) {
30
+ if (fs.existsSync(path.join(cwd, 'package.json'))) return true;
31
+ for (const d of ['src', 'app', 'pages', 'site', 'public', 'components', 'lib']) {
32
+ if (fs.existsSync(path.join(cwd, d))) return true;
33
+ }
34
+ return false;
35
+ }
36
+
37
+ /**
38
+ * The most recent critique snapshot across all targets. Filenames are
39
+ * timestamp-prefixed (`<iso>__<slug>.md`), so a lexical sort is chronological.
40
+ * Parses the small frontmatter for score + P0/P1 counts.
41
+ */
42
+ function latestCritique(cwd) {
43
+ try {
44
+ const dir = getCritiqueDir(cwd);
45
+ if (!fs.existsSync(dir)) return null;
46
+ const files = fs.readdirSync(dir).filter((f) => f.endsWith('.md')).sort();
47
+ if (!files.length) return null;
48
+ const newest = files[files.length - 1];
49
+ const text = fs.readFileSync(path.join(dir, newest), 'utf-8');
50
+ const front = text.split('---')[1] || '';
51
+ const get = (k) => {
52
+ const m = front.match(new RegExp(`^${k}:\\s*(.+)$`, 'm'));
53
+ return m ? m[1].trim() : null;
54
+ };
55
+ const num = (v) => {
56
+ const n = Number(v);
57
+ return Number.isFinite(n) ? n : null;
58
+ };
59
+ return {
60
+ slug: get('slug'),
61
+ score: num(get('score')),
62
+ p0: num(get('p0')),
63
+ p1: num(get('p1')),
64
+ timestamp: get('timestamp'),
65
+ file: path.relative(cwd, path.join(dir, newest)),
66
+ };
67
+ } catch {
68
+ return null;
69
+ }
70
+ }
71
+
72
+ /** Branch + a scope hint: files changed vs the default branch, else working tree. */
73
+ function gitSignals(cwd) {
74
+ const run = (args, { trim = true } = {}) => {
75
+ try {
76
+ const out = execFileSync('git', args, {
77
+ cwd,
78
+ encoding: 'utf-8',
79
+ stdio: ['ignore', 'pipe', 'ignore'],
80
+ });
81
+ return trim ? out.trim() : out;
82
+ } catch {
83
+ return null;
84
+ }
85
+ };
86
+ if (run(['rev-parse', '--is-inside-work-tree']) !== 'true') {
87
+ return { isRepo: false, branch: null, base: null, changedFiles: [], changedCount: 0 };
88
+ }
89
+ const branch = run(['rev-parse', '--abbrev-ref', 'HEAD']);
90
+ let base = null;
91
+ for (const b of ['main', 'master']) {
92
+ if (run(['rev-parse', '--verify', '--quiet', b]) !== null) {
93
+ base = b;
94
+ break;
95
+ }
96
+ }
97
+ const diffBase = base && branch && branch !== base ? base : null;
98
+ const fromDiff = diffBase ? run(['diff', '--name-only', `${diffBase}...HEAD`]) : null;
99
+ // porcelain lines are `XY PATH`: a 2-char status + a space, then the path.
100
+ // Don't trim the combined output — an unstaged-modified line starts with a
101
+ // leading space (` M path`), and a global trim would eat the first line's
102
+ // status column and shift the slice. Renames render as `old -> new`.
103
+ const fromStatus = run(['-c', 'core.quotepath=false', 'status', '--porcelain'], { trim: false });
104
+ let changed = [];
105
+ if (fromDiff) {
106
+ changed = fromDiff.split('\n').filter(Boolean);
107
+ } else if (fromStatus) {
108
+ changed = fromStatus.split(/\r?\n/).filter(Boolean).map((l) => {
109
+ const p = l.slice(3);
110
+ const arrow = p.indexOf(' -> ');
111
+ return arrow === -1 ? p : p.slice(arrow + 4);
112
+ });
113
+ }
114
+ return {
115
+ isRepo: true,
116
+ branch,
117
+ base: diffBase,
118
+ changedFiles: changed.slice(0, 50),
119
+ changedCount: changed.length,
120
+ };
121
+ }
122
+
123
+ const COMMON_DEV_PORTS = [4321, 3000, 5173, 5174, 8080, 8000, 4200];
124
+
125
+ function probePort(port, timeout = 250) {
126
+ return new Promise((resolve) => {
127
+ const sock = new net.Socket();
128
+ let settled = false;
129
+ const finish = (ok) => {
130
+ if (settled) return;
131
+ settled = true;
132
+ try { sock.destroy(); } catch { /* ignore */ }
133
+ resolve(ok);
134
+ };
135
+ sock.setTimeout(timeout);
136
+ sock.once('connect', () => finish(true));
137
+ sock.once('timeout', () => finish(false));
138
+ sock.once('error', () => finish(false));
139
+ sock.connect(port, '127.0.0.1');
140
+ });
141
+ }
142
+
143
+ async function devServerSignals() {
144
+ const open = [];
145
+ await Promise.all(
146
+ COMMON_DEV_PORTS.map(async (p) => {
147
+ if (await probePort(p)) open.push(p);
148
+ }),
149
+ );
150
+ open.sort((a, b) => a - b);
151
+ return { running: open.length > 0, ports: open };
152
+ }
153
+
154
+ // Extensions the detector scans (mirrors the engine's walkDir set + HTML).
155
+ const SCANNABLE_EXT = new Set([
156
+ '.html', '.htm', '.css', '.scss',
157
+ '.jsx', '.tsx', '.js', '.ts', '.vue', '.svelte', '.astro',
158
+ ]);
159
+ // Where UI source typically lives. The detector walks these and skips
160
+ // node_modules / dist / build / .next / .nuxt automatically.
161
+ const SOURCE_DIRS = ['src', 'app', 'components', 'pages', 'public'];
162
+
163
+ /**
164
+ * Local paths the agent should point the bundled detector at — never a URL.
165
+ * A URL means a costly Puppeteer browser render, and a probed dev-server port
166
+ * may not even belong to this project. An HTML *file* or a source tree is
167
+ * scanned by the cheap, jsdom-free static engine. This script does NOT run the
168
+ * detector; it just surfaces the target(s) so the agent can run
169
+ * `node <scripts>/detect.mjs --json <targets>` and fold the hits in.
170
+ */
171
+ function scanTargets(cwd, git) {
172
+ // 1. Dirty tree wins: scan exactly the markup/style files in flight. It's
173
+ // what the user is working on, it's a small set, and it's local.
174
+ if (git.isRepo && git.changedFiles.length) {
175
+ const changed = git.changedFiles
176
+ .filter((f) => SCANNABLE_EXT.has(path.extname(f).toLowerCase()))
177
+ .filter((f) => fs.existsSync(path.join(cwd, f)));
178
+ if (changed.length) return { targets: changed.slice(0, 50), via: 'git-changes' };
179
+ }
180
+ // 2. Otherwise scan the local source dirs that exist.
181
+ const dirs = SOURCE_DIRS.filter((d) => fs.existsSync(path.join(cwd, d)));
182
+ if (dirs.length) return { targets: dirs, via: 'source-dir' };
183
+ // 3. A root HTML entry, or the project root as a last resort when there's
184
+ // code but no conventional source dir (walkDir still skips heavy dirs).
185
+ if (fs.existsSync(path.join(cwd, 'index.html'))) return { targets: ['index.html'], via: 'html' };
186
+ if (hasCode(cwd)) return { targets: ['.'], via: 'root' };
187
+ return { targets: [], via: null };
188
+ }
189
+
190
+ export async function gatherSignals(cwd = process.cwd()) {
191
+ const ctx = loadContext(cwd);
192
+ const git = gitSignals(cwd);
193
+ return {
194
+ setup: {
195
+ hasProduct: ctx.hasProduct,
196
+ productPath: ctx.productPath,
197
+ hasDesign: ctx.hasDesign,
198
+ designPath: ctx.designPath,
199
+ hasCode: hasCode(cwd),
200
+ register: extractRegister(ctx.product),
201
+ platform: extractPlatform(ctx.product),
202
+ },
203
+ critique: { latest: latestCritique(cwd) },
204
+ git,
205
+ devServer: await devServerSignals(),
206
+ scan: scanTargets(cwd, git),
207
+ };
208
+ }
209
+
210
+ async function cli() {
211
+ const signals = await gatherSignals(process.cwd());
212
+ process.stdout.write(`${JSON.stringify(signals, null, 2)}\n`);
213
+ }
214
+
215
+ function invokedAsScript() {
216
+ const arg = process.argv[1];
217
+ if (!arg) return false;
218
+ try {
219
+ return fs.realpathSync(arg) === fs.realpathSync(fileURLToPath(import.meta.url));
220
+ } catch {
221
+ return false;
222
+ }
223
+ }
224
+
225
+ if (invokedAsScript()) {
226
+ cli();
227
+ }