@appdirect/design-system 0.0.19 → 0.0.21

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 (47) hide show
  1. package/README.md +21 -0
  2. package/bin/ad-sync-agents.mjs +542 -0
  3. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/CustomBottomToolbar.module.css +24 -1
  4. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.js +2 -1
  5. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.tsx +3 -0
  6. package/dist/ComplexComponents/DataTable/CustomToolbarAlertBannerContent/CustomToolbarAlertBannerContent.module.css +9 -1
  7. package/dist/ComplexComponents/DataTable/CustomTopToolbar/CustomTopToolbar.module.css +7 -0
  8. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/DateRangeSelectorFilter.module.css +7 -0
  9. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.js +1 -1
  10. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.tsx +1 -0
  11. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.js +4 -2
  12. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.module.css +16 -0
  13. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.tsx +6 -3
  14. package/dist/ComplexComponents/DataTable/CustomTopToolbar/index.js +2 -2
  15. package/dist/ComplexComponents/DataTable/CustomTopToolbar/index.tsx +11 -8
  16. package/dist/ComplexComponents/DataTable/DataTableGrid/DataTableGrid.module.css +17 -3
  17. package/dist/ComplexComponents/DataTable/DataTableGrid/index.js +1 -1
  18. package/dist/ComplexComponents/DataTable/DataTableGrid/index.tsx +2 -2
  19. package/dist/ComplexComponents/DataTable/ToolbarAlertBanner/ToolbarAlertBanner.module.css +4 -1
  20. package/dist/DESIGN.md +49 -7
  21. package/dist/agent-kit/README.md +11 -0
  22. package/dist/agent-kit/manifest.json +81 -0
  23. package/dist/agent-kit/micro-ui/CLAUDE.md +1 -0
  24. package/dist/agent-kit/micro-ui/micro-ui.AGENTS.md +62 -0
  25. package/dist/agent-kit/rules/accessibility.mdc +46 -0
  26. package/dist/agent-kit/rules/module-federation.mdc +30 -0
  27. package/dist/agent-kit/rules/react-stack.mdc +73 -0
  28. package/dist/agent-kit/rules/testing.mdc +44 -0
  29. package/dist/agent-kit/skills/design-feature/SKILL.md +205 -0
  30. package/dist/agent-kit/skills/developer-handoff/SKILL.md +192 -0
  31. package/dist/agent-kit/skills/figma-mcp-integration/SKILL.md +134 -0
  32. package/dist/agent-kit/skills/figma-to-page/SKILL.md +24 -0
  33. package/dist/agent-kit/skills/mantine-combobox/SKILL.md +73 -0
  34. package/dist/agent-kit/skills/mantine-combobox/references/api.md +199 -0
  35. package/dist/agent-kit/skills/mantine-combobox/references/patterns.md +279 -0
  36. package/dist/agent-kit/skills/mantine-custom-components/SKILL.md +112 -0
  37. package/dist/agent-kit/skills/mantine-custom-components/references/api.md +407 -0
  38. package/dist/agent-kit/skills/mantine-custom-components/references/patterns.md +431 -0
  39. package/dist/agent-kit/skills/mantine-form/SKILL.md +103 -0
  40. package/dist/agent-kit/skills/mantine-form/references/api.md +313 -0
  41. package/dist/agent-kit/skills/mantine-form/references/patterns.md +310 -0
  42. package/dist/agent-kit/skills/prototype-page/SKILL.md +82 -0
  43. package/dist/contracts/index.json +1 -1
  44. package/dist/css/mantine.css +4 -4
  45. package/dist/skills/design-feature/SKILL.md +205 -0
  46. package/dist/stories/index.json +1 -1
  47. package/package.json +8 -4
package/README.md CHANGED
@@ -26,6 +26,8 @@ Peer dependencies (install at the versions declared by this package):
26
26
  | Design spec | `@appdirect/design-system/DESIGN.md` | Canonical `apps/design-system/DESIGN.md` (token tables + prose) |
27
27
  | CLI | `ds-audit` | Audit a prototype or app against contracts |
28
28
  | CLI | `ad-sync-design-md` | Copy `DESIGN.md` into the consumer repo (`postinstall` / `sync-design-docs`) |
29
+ | CLI | `ad-sync-agents` | Copy micro-UI agent kit (AGENTS.md, rules, skills) into the consumer (`postinstall` / `sync-agents`) |
30
+ | Agent kit | `dist/agent-kit/` | Source for `ad-sync-agents` |
29
31
 
30
32
  Bundlers (Rspack, webpack, Vite, Next) should resolve the package entry to **`.js`**. You do **not** need `transpilePackages` / SWC includes for this package’s TypeScript. Keep loading `*.module.css` from the package with your CSS-modules rule.
31
33
 
@@ -46,6 +48,25 @@ Do **not** hand-copy the design spec. Wire consumers to pull the published file
46
48
  - Repo-root destination: `DESIGN_MD_PATH=DESIGN.md` or `ad-sync-design-md --out DESIGN.md`
47
49
  - Authoring source of truth in this monorepo: [`apps/design-system/DESIGN.md`](../../apps/design-system/DESIGN.md)
48
50
 
51
+ ## Keep agent kit in sync (micro UIs)
52
+
53
+ ```json
54
+ {
55
+ "scripts": {
56
+ "postinstall": "ad-sync-design-md && ad-sync-agents",
57
+ "sync-agents": "ad-sync-agents",
58
+ "sync-agents:force": "ad-sync-agents --force"
59
+ }
60
+ }
61
+ ```
62
+
63
+ - Default: add missing AGENTS.md / CLAUDE.md / `.cursor/rules` / skills; refresh untouched kit docs/skills; never overwrite existing rules
64
+ - `--force`: overwrite kit AGENTS.md, CLAUDE.md, and skills (skill dirs deleted/recreated; rules still add-only)
65
+ - Commit `.claude/skills/.ad-agent-kit.json` so refreshes work after a kit bump on fresh clones/CI
66
+ - `postinstall` errors are best-effort (warn + exit 0); explicit `npm run sync-agents` still exits 1 on failure
67
+ - `prototype-page` / `figma-to-page` sync only when `standalone/` exists
68
+ - Kit source in this monorepo: [`agent-kit/`](./agent-kit/)
69
+
49
70
  ## App usage
50
71
 
51
72
  Load token CSS once near the app root (standalone prototypes often use this package’s CSS re-exports; the tokens package is the same files):
@@ -0,0 +1,542 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Sync the micro-UI agent kit from @appdirect/design-system into a consumer.
4
+ *
5
+ * Safe (default): per destination — write only if missing for rules; docs and
6
+ * skills add if missing or refresh when the local hash still matches the last
7
+ * kit write.
8
+ *
9
+ * --force: overwrite kit AGENTS.md, CLAUDE.md, and skills (skill directories are
10
+ * deleted and recreated). Rules never overwrite.
11
+ *
12
+ * prototype-page / figma-to-page require a standalone/ directory.
13
+ *
14
+ * Intended for consumer package.json:
15
+ * "postinstall": "... ad-sync-agents"
16
+ * "sync-agents": "ad-sync-agents"
17
+ * "sync-agents:force": "ad-sync-agents --force"
18
+ *
19
+ * Commit `.claude/skills/.ad-agent-kit.json` so teammates and CI can refresh
20
+ * untouched kit files after a package bump.
21
+ */
22
+
23
+ import { createHash } from 'node:crypto';
24
+ import {
25
+ cpSync,
26
+ existsSync,
27
+ lstatSync,
28
+ mkdirSync,
29
+ readFileSync,
30
+ readdirSync,
31
+ realpathSync,
32
+ rmSync,
33
+ symlinkSync,
34
+ writeFileSync,
35
+ } from 'node:fs';
36
+ import path from 'node:path';
37
+ import { fileURLToPath, pathToFileURL } from 'node:url';
38
+
39
+ const PACKAGE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
40
+ const DEFAULT_KIT = path.join(PACKAGE_ROOT, 'dist', 'agent-kit');
41
+ const STATE_FILE = '.claude/skills/.ad-agent-kit.json';
42
+
43
+ export function parseArgs(argv) {
44
+ const args = { force: false, dryRun: false, help: false };
45
+ for (const arg of argv) {
46
+ if (arg === '--help' || arg === '-h') args.help = true;
47
+ else if (arg === '--dry-run') args.dryRun = true;
48
+ else if (arg === '--force') args.force = true;
49
+ else throw new Error(`Unknown argument: ${arg}`);
50
+ }
51
+ return args;
52
+ }
53
+
54
+ export function resolveProjectRoot(options = {}) {
55
+ const initCwd = Object.prototype.hasOwnProperty.call(options, 'initCwd')
56
+ ? options.initCwd
57
+ : process.env.INIT_CWD;
58
+ const cwd = Object.prototype.hasOwnProperty.call(options, 'cwd')
59
+ ? options.cwd
60
+ : process.cwd();
61
+ if (typeof initCwd === 'string' && initCwd.length > 0 && path.isAbsolute(initCwd)) {
62
+ return initCwd;
63
+ }
64
+ return cwd;
65
+ }
66
+
67
+ function isDesignSystemRepo(projectRoot) {
68
+ return (
69
+ existsSync(path.join(projectRoot, 'packages', 'components', 'agent-kit')) ||
70
+ existsSync(path.join(projectRoot, 'apps', 'design-system', 'DESIGN.md'))
71
+ );
72
+ }
73
+
74
+ /**
75
+ * Micro UIs (and prototypes copied from micro-ui-ts) expose ./Root via Module Federation
76
+ * and keep the Root entry under src/components/Root.
77
+ */
78
+ export function isMicroUiProject(projectRoot) {
79
+ const rootCandidates = [
80
+ path.join(projectRoot, 'src', 'components', 'Root'),
81
+ path.join(projectRoot, 'src', 'components', 'Root.tsx'),
82
+ path.join(projectRoot, 'src', 'components', 'Root', 'index.tsx'),
83
+ path.join(projectRoot, 'src', 'components', 'Root', 'index.ts'),
84
+ ];
85
+ const hasRoot = rootCandidates.some((candidate) => existsSync(candidate));
86
+ if (!hasRoot) return false;
87
+
88
+ const bundlerConfigs = [
89
+ 'rspack.config.js',
90
+ 'rspack.config.cjs',
91
+ 'rspack.config.mjs',
92
+ 'rspack.config.ts',
93
+ 'webpack.config.js',
94
+ 'webpack.config.cjs',
95
+ 'webpack.config.mjs',
96
+ 'webpack.config.ts',
97
+ ];
98
+ for (const file of bundlerConfigs) {
99
+ const configPath = path.join(projectRoot, file);
100
+ if (!existsSync(configPath)) continue;
101
+ let text = '';
102
+ try {
103
+ text = readFileSync(configPath, 'utf8');
104
+ } catch {
105
+ continue;
106
+ }
107
+ const hasFederation = text.includes('ModuleFederation');
108
+ const hasExposeRoot =
109
+ text.includes('./Root') || text.includes('"./Root"') || text.includes("'./Root'");
110
+ if (hasFederation && hasExposeRoot) {
111
+ return true;
112
+ }
113
+ }
114
+ return false;
115
+ }
116
+
117
+ function collectFiles(dir, relativeBase = '', out = []) {
118
+ if (!existsSync(dir)) return out;
119
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
120
+ const full = path.join(dir, entry.name);
121
+ const rel = path.join(relativeBase, entry.name).replace(/\\/g, '/');
122
+ if (entry.isDirectory()) {
123
+ collectFiles(full, rel, out);
124
+ } else if (entry.isFile() || entry.isSymbolicLink()) {
125
+ out.push({ full, rel });
126
+ }
127
+ }
128
+ return out;
129
+ }
130
+
131
+ function hashBytes(buffer) {
132
+ return createHash('sha256').update(buffer).digest('hex');
133
+ }
134
+
135
+ function hashFile(filePath) {
136
+ return hashBytes(readFileSync(filePath));
137
+ }
138
+
139
+ function hashTree(dir) {
140
+ const files = collectFiles(dir).sort((a, b) => a.rel.localeCompare(b.rel));
141
+ const h = createHash('sha256');
142
+ for (const file of files) {
143
+ h.update(file.rel);
144
+ h.update('\0');
145
+ h.update(readFileSync(file.full));
146
+ h.update('\0');
147
+ }
148
+ return h.digest('hex');
149
+ }
150
+
151
+ function readState(projectRoot) {
152
+ const statePath = path.join(projectRoot, STATE_FILE);
153
+ if (!existsSync(statePath)) return { version: null, files: {} };
154
+ try {
155
+ return JSON.parse(readFileSync(statePath, 'utf8'));
156
+ } catch {
157
+ return { version: null, files: {} };
158
+ }
159
+ }
160
+
161
+ function writeState(projectRoot, state, { dryRun }) {
162
+ if (dryRun) return;
163
+ const statePath = path.join(projectRoot, STATE_FILE);
164
+ mkdirSync(path.dirname(statePath), { recursive: true });
165
+ writeFileSync(statePath, `${JSON.stringify(state, null, 2)}\n`, 'utf8');
166
+ }
167
+
168
+ function copyFile(src, dest, { dryRun }) {
169
+ if (dryRun) return;
170
+ mkdirSync(path.dirname(dest), { recursive: true });
171
+ cpSync(src, dest);
172
+ }
173
+
174
+ function copyDir(src, dest, { dryRun }) {
175
+ if (dryRun) return;
176
+ mkdirSync(path.dirname(dest), { recursive: true });
177
+ if (existsSync(dest)) {
178
+ rmSync(dest, { recursive: true, force: true });
179
+ }
180
+ cpSync(src, dest, { recursive: true });
181
+ }
182
+
183
+ /**
184
+ * Convert a Cursor .mdc rule into a Claude Code .md rule (same as micro-ui-ts rules:sync).
185
+ */
186
+ export function renderClaudeRule(mdcText, sourceFile) {
187
+ const match = mdcText.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
188
+ if (!match) {
189
+ throw new Error(`${sourceFile} has no frontmatter`);
190
+ }
191
+ const fields = {};
192
+ for (const line of match[1].split('\n')) {
193
+ const colon = line.indexOf(':');
194
+ if (colon <= 0) continue;
195
+ const key = line.slice(0, colon);
196
+ if (!/^[A-Za-z0-9_]+$/.test(key)) continue;
197
+ fields[key] = line.slice(colon + 1).trim();
198
+ }
199
+ const globs = (fields.globs ?? '')
200
+ .split(',')
201
+ .map((glob) => glob.trim())
202
+ .filter(Boolean);
203
+ const body = match[2].replace(/^\n+/, '');
204
+ const frontmatter = globs.length
205
+ ? `---\npaths:\n${globs.map((glob) => ` - "${glob}"`).join('\n')}\n---\n\n`
206
+ : '';
207
+ return `${frontmatter}<!-- Generated from .cursor/rules/${sourceFile} by ad-sync-agents. Edit that file instead. -->\n\n${body}`;
208
+ }
209
+
210
+ function syncClaudeRuleFromMdc(projectRoot, mdcDestRelative, { dryRun, log, warn = console.warn }) {
211
+ const mdcPath = path.join(projectRoot, mdcDestRelative);
212
+ if (!existsSync(mdcPath)) return;
213
+ const base = path.basename(mdcDestRelative, '.mdc');
214
+ const claudeDest = path.join(projectRoot, '.claude', 'rules', `${base}.md`);
215
+ let rendered;
216
+ try {
217
+ rendered = renderClaudeRule(readFileSync(mdcPath, 'utf8'), path.basename(mdcDestRelative));
218
+ } catch (err) {
219
+ warn(`[ad-sync-agents] Skip Claude rule for ${mdcDestRelative}: ${err.message}`);
220
+ return;
221
+ }
222
+ if (existsSync(claudeDest) && readFileSync(claudeDest, 'utf8') === rendered) {
223
+ return;
224
+ }
225
+ if (!dryRun) {
226
+ mkdirSync(path.dirname(claudeDest), { recursive: true });
227
+ writeFileSync(claudeDest, rendered, 'utf8');
228
+ }
229
+ log(`[ad-sync-agents] Synced .claude/rules/${base}.md`);
230
+ }
231
+
232
+ function ensureCursorSkillsSymlink(projectRoot, { dryRun, log }) {
233
+ const linkPath = path.join(projectRoot, '.cursor', 'skills');
234
+ const target = '../.claude/skills';
235
+ let stat = null;
236
+ try {
237
+ stat = lstatSync(linkPath);
238
+ } catch {
239
+ // missing
240
+ }
241
+ if (stat) {
242
+ if (!stat.isSymbolicLink() && stat.isDirectory()) {
243
+ log(
244
+ '[ad-sync-agents] `.cursor/skills` exists and is not a symlink; kit skills are only visible to Claude Code'
245
+ );
246
+ }
247
+ return;
248
+ }
249
+ if (dryRun) {
250
+ log(`[ad-sync-agents] Dry run: would link .cursor/skills -> ${target}`);
251
+ return;
252
+ }
253
+ mkdirSync(path.join(projectRoot, '.cursor'), { recursive: true });
254
+ mkdirSync(path.join(projectRoot, '.claude', 'skills'), { recursive: true });
255
+ try {
256
+ symlinkSync(target, linkPath);
257
+ log(`[ad-sync-agents] Linked .cursor/skills -> ${target}`);
258
+ } catch (err) {
259
+ log(`[ad-sync-agents] Could not link .cursor/skills: ${err.message}`);
260
+ }
261
+ }
262
+
263
+ function meetsRequires(projectRoot, requires) {
264
+ if (!requires) return true;
265
+ if (requires === 'standalone') {
266
+ return existsSync(path.join(projectRoot, 'standalone'));
267
+ }
268
+ return existsSync(path.join(projectRoot, requires));
269
+ }
270
+
271
+ function recordStateHash(nextFiles, entry, result) {
272
+ if (result.hash && result.status !== 'skipped' && result.status !== 'kept') {
273
+ nextFiles[entry.id] = { hash: result.hash, dest: entry.dest };
274
+ }
275
+ }
276
+
277
+ function syncHashedPath({
278
+ id,
279
+ destRelative,
280
+ nextHash,
281
+ exists,
282
+ currentHash,
283
+ prevHash,
284
+ force,
285
+ dryRun,
286
+ log,
287
+ write,
288
+ forceNote,
289
+ }) {
290
+ if (!exists) {
291
+ if (dryRun) {
292
+ log(`[ad-sync-agents] Dry run: would add ${destRelative}`);
293
+ return { id, status: 'dry-run', hash: nextHash };
294
+ }
295
+ write();
296
+ log(`[ad-sync-agents] Added ${destRelative}`);
297
+ return { id, status: 'added', hash: nextHash };
298
+ }
299
+
300
+ if (force) {
301
+ if (dryRun) {
302
+ log(`[ad-sync-agents] Dry run: would overwrite ${destRelative}`);
303
+ return { id, status: 'dry-run', hash: nextHash };
304
+ }
305
+ if (forceNote) log(forceNote);
306
+ write();
307
+ log(`[ad-sync-agents] Updated ${destRelative} (--force)`);
308
+ return { id, status: 'updated', hash: nextHash };
309
+ }
310
+
311
+ if (currentHash === nextHash) {
312
+ log(`[ad-sync-agents] Already in sync ${destRelative}`);
313
+ return { id, status: 'unchanged', hash: nextHash };
314
+ }
315
+
316
+ if (prevHash && currentHash === prevHash) {
317
+ if (dryRun) {
318
+ log(`[ad-sync-agents] Dry run: would refresh ${destRelative}`);
319
+ return { id, status: 'dry-run', hash: nextHash };
320
+ }
321
+ write();
322
+ log(`[ad-sync-agents] Refreshed ${destRelative}`);
323
+ return { id, status: 'refreshed', hash: nextHash };
324
+ }
325
+
326
+ log(`[ad-sync-agents] Keep local edits ${destRelative}`);
327
+ return { id, status: 'kept', hash: prevHash || currentHash };
328
+ }
329
+
330
+ function syncDoc(entry, kitRoot, projectRoot, state, { force, dryRun, log }) {
331
+ const src = path.join(kitRoot, entry.source);
332
+ const dest = path.join(projectRoot, entry.dest);
333
+ if (!existsSync(src)) {
334
+ return { id: entry.id, status: 'skipped', reason: 'source-missing' };
335
+ }
336
+ const nextHash = hashFile(src);
337
+ const exists = existsSync(dest);
338
+ const prevHash = state.files?.[entry.id]?.hash;
339
+ const currentHash = exists ? hashFile(dest) : null;
340
+ return syncHashedPath({
341
+ id: entry.id,
342
+ destRelative: entry.dest,
343
+ nextHash,
344
+ exists,
345
+ currentHash,
346
+ prevHash,
347
+ force,
348
+ dryRun,
349
+ log,
350
+ write: () => copyFile(src, dest, { dryRun }),
351
+ });
352
+ }
353
+
354
+ function syncRule(entry, kitRoot, projectRoot, { dryRun, log, warn }) {
355
+ const src = path.join(kitRoot, entry.source);
356
+ const dest = path.join(projectRoot, entry.dest);
357
+ if (!existsSync(src)) {
358
+ return { id: entry.id, status: 'skipped', reason: 'source-missing' };
359
+ }
360
+ if (existsSync(dest)) {
361
+ log(`[ad-sync-agents] Keep existing ${entry.dest}`);
362
+ syncClaudeRuleFromMdc(projectRoot, entry.dest, { dryRun, log, warn });
363
+ return { id: entry.id, status: 'kept' };
364
+ }
365
+ if (dryRun) {
366
+ log(`[ad-sync-agents] Dry run: would write ${entry.dest}`);
367
+ return { id: entry.id, status: 'dry-run' };
368
+ }
369
+ copyFile(src, dest, { dryRun });
370
+ log(`[ad-sync-agents] Added ${entry.dest}`);
371
+ syncClaudeRuleFromMdc(projectRoot, entry.dest, { dryRun, log, warn });
372
+ return { id: entry.id, status: 'added' };
373
+ }
374
+
375
+ function syncSkill(entry, kitRoot, projectRoot, state, { force, dryRun, log }) {
376
+ const src = path.join(kitRoot, entry.source);
377
+ const dest = path.join(projectRoot, entry.dest);
378
+ if (!existsSync(src)) {
379
+ return { id: entry.id, status: 'skipped', reason: 'source-missing' };
380
+ }
381
+ if (!meetsRequires(projectRoot, entry.requires)) {
382
+ log(`[ad-sync-agents] Skip ${entry.id} (requires ${entry.requires}/, not present)`);
383
+ return { id: entry.id, status: 'skipped', reason: 'requires-missing' };
384
+ }
385
+
386
+ const nextHash = hashTree(src);
387
+ const exists = existsSync(dest);
388
+ const prevHash = state.files?.[entry.id]?.hash;
389
+ const currentHash = exists ? hashTree(dest) : null;
390
+ const locallyModified =
391
+ exists && currentHash !== nextHash && (!prevHash || currentHash !== prevHash);
392
+
393
+ return syncHashedPath({
394
+ id: entry.id,
395
+ destRelative: entry.dest,
396
+ nextHash,
397
+ exists,
398
+ currentHash,
399
+ prevHash,
400
+ force,
401
+ dryRun,
402
+ log,
403
+ forceNote: locallyModified
404
+ ? `[ad-sync-agents] --force: replacing locally modified ${entry.dest} (skill directory is deleted and recreated)`
405
+ : `[ad-sync-agents] --force: replacing ${entry.dest} (skill directory is deleted and recreated)`,
406
+ write: () => copyDir(src, dest, { dryRun }),
407
+ });
408
+ }
409
+
410
+ export async function syncAgents({
411
+ kitRoot = DEFAULT_KIT,
412
+ projectRoot = resolveProjectRoot(),
413
+ packageVersion = null,
414
+ force = false,
415
+ dryRun = false,
416
+ log = console.log,
417
+ warn = console.warn,
418
+ } = {}) {
419
+ if (isDesignSystemRepo(projectRoot)) {
420
+ log('[ad-sync-agents] Skip: project root looks like ad-design-system');
421
+ return { status: 'skipped', reason: 'design-system-repo' };
422
+ }
423
+
424
+ if (!isMicroUiProject(projectRoot)) {
425
+ log(
426
+ '[ad-sync-agents] Skip: not a micro UI (need src/components/Root and Module Federation exposes ./Root in rspack/webpack config)'
427
+ );
428
+ return { status: 'skipped', reason: 'not-micro-ui' };
429
+ }
430
+
431
+ const manifestPath = path.join(kitRoot, 'manifest.json');
432
+ if (!existsSync(manifestPath)) {
433
+ warn(`[ad-sync-agents] Kit not found at ${kitRoot}`);
434
+ warn('[ad-sync-agents] Skipping. Build or upgrade @appdirect/design-system to enable sync.');
435
+ return { status: 'skipped', reason: 'source-missing' };
436
+ }
437
+
438
+ let manifest;
439
+ try {
440
+ manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
441
+ } catch (err) {
442
+ warn(`[ad-sync-agents] Invalid manifest at ${manifestPath}: ${err.message}`);
443
+ return { status: 'skipped', reason: 'invalid-manifest' };
444
+ }
445
+
446
+ const state = readState(projectRoot);
447
+ const results = { docs: [], rules: [], skills: [] };
448
+ const nextFiles = { ...(state.files || {}) };
449
+
450
+ for (const entry of manifest.docs ?? []) {
451
+ const result = syncDoc(entry, kitRoot, projectRoot, state, { force, dryRun, log });
452
+ results.docs.push(result);
453
+ recordStateHash(nextFiles, entry, result);
454
+ }
455
+ for (const entry of manifest.rules ?? []) {
456
+ results.rules.push(syncRule(entry, kitRoot, projectRoot, { dryRun, log, warn }));
457
+ }
458
+
459
+ ensureCursorSkillsSymlink(projectRoot, { dryRun, log });
460
+
461
+ for (const entry of manifest.skills ?? []) {
462
+ const result = syncSkill(entry, kitRoot, projectRoot, state, { force, dryRun, log });
463
+ results.skills.push(result);
464
+ recordStateHash(nextFiles, entry, result);
465
+ }
466
+
467
+ let version = packageVersion;
468
+ if (!version) {
469
+ try {
470
+ version = JSON.parse(readFileSync(path.join(PACKAGE_ROOT, 'package.json'), 'utf8')).version;
471
+ } catch {
472
+ version = null;
473
+ }
474
+ }
475
+
476
+ writeState(
477
+ projectRoot,
478
+ { version, package: '@appdirect/design-system', files: nextFiles },
479
+ { dryRun }
480
+ );
481
+
482
+ return { status: 'ok', results };
483
+ }
484
+
485
+ function printHelp() {
486
+ console.log(`Usage: ad-sync-agents [--force] [--dry-run]
487
+
488
+ Copies the micro-UI agent kit from @appdirect/design-system/dist/agent-kit
489
+ into the consumer project (AGENTS.md, CLAUDE.md, .cursor/rules, .claude/skills).
490
+
491
+ Only runs in micro UI projects (src/components/Root + Module Federation ./Root
492
+ in rspack/webpack config). Skips other apps quietly.
493
+
494
+ Default: add missing files; refresh untouched kit docs/skills; never overwrite rules.
495
+ --force: overwrite kit AGENTS.md, CLAUDE.md, and skills (skill directories are
496
+ deleted and recreated; rules still add-only).
497
+
498
+ Commit .claude/skills/.ad-agent-kit.json so refreshes work across clones/CI.
499
+ Postinstall errors warn and exit 0 so npm install is not blocked.
500
+ `);
501
+ }
502
+
503
+ /**
504
+ * True when this file is the process entrypoint. Resolve symlinks so npm's
505
+ * node_modules/.bin/ad-sync-agents link still matches import.meta.url.
506
+ */
507
+ export function isCliEntrypoint({
508
+ argv1 = process.argv[1],
509
+ moduleUrl = import.meta.url,
510
+ realpathFn = realpathSync,
511
+ } = {}) {
512
+ if (!argv1) return false;
513
+ try {
514
+ return moduleUrl === pathToFileURL(realpathFn(path.resolve(argv1))).href;
515
+ } catch {
516
+ return false;
517
+ }
518
+ }
519
+
520
+ if (isCliEntrypoint()) {
521
+ try {
522
+ const args = parseArgs(process.argv.slice(2));
523
+ if (args.help) {
524
+ printHelp();
525
+ process.exit(0);
526
+ }
527
+ const result = await syncAgents({
528
+ force: args.force,
529
+ dryRun: args.dryRun,
530
+ });
531
+ if (result.status === 'skipped') {
532
+ process.exit(0);
533
+ }
534
+ } catch (err) {
535
+ console.error(`[ad-sync-agents] ${err.message}`);
536
+ if (process.env.npm_lifecycle_event === 'postinstall') {
537
+ console.warn('[ad-sync-agents] Continuing after postinstall error (sync is best-effort).');
538
+ process.exit(0);
539
+ }
540
+ process.exit(1);
541
+ }
542
+ }
@@ -4,4 +4,27 @@
4
4
 
5
5
  .pageSize {
6
6
  flex-shrink: 0;
7
- }
7
+ }
8
+
9
+ /* The page-size select reads as plain text with a chevron: no fill or border, even on hover and
10
+ focus. The selectors are deliberately as specific as the global Input state rules
11
+ (:hover / :focus) so they win without !important. */
12
+ .pageSize .pageSizeInput[data-variant="unstyled"]:not([data-error]):not([data-disabled]) {
13
+ background: transparent;
14
+ border-color: transparent;
15
+ padding-inline-start: 0;
16
+ cursor: pointer;
17
+ }
18
+
19
+ .pageSizeChevron {
20
+ width: var(--ad-icon-size-lg);
21
+ height: var(--ad-icon-size-lg);
22
+ flex-shrink: 0;
23
+ color: var(--ad-color-text-default);
24
+ }
25
+
26
+ /* The global Input section rule pads both sides, which squeezes the chevron to a few px. */
27
+ .pageSize .pageSizeSection[data-position] {
28
+ padding-inline: 0;
29
+ justify-content: flex-end;
30
+ }
@@ -5,6 +5,7 @@ import React, { useMemo } from "react";
5
5
  import { Box, Flex, Select, ActionIcon, Text } from "@mantine/core";
6
6
  import { RiArrowLeftSLine as PreviousPageIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
7
7
  import { RiArrowRightSLine as NextPageIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
8
+ import { RiArrowDropDownFill as DropdownIcon } from "@remixicon/react"; // DS-ADAPT: down triangle for the page-size select
8
9
  import { translate } from "../translations/index.js"; // DS-ADAPT: translate lives in DataTable/translations
9
10
  import { getFormattedPageCount, getFormattedPageSize, getNumOfRowsPerPageOptions } from "./utils.js";
10
11
  import styles from "./CustomBottomToolbar.module.css";
@@ -17,7 +18,7 @@ const CustomBottomToolbar = ({ paginationState, onPageSizeChange, onNextPage, on
17
18
  };
18
19
  const formattedPageLegend = getFormattedPageCount(paginationState.pageIndex, paginationState.pageSize, rowCount);
19
20
  const numOfRowsPerPageOptions = useMemo(() => getNumOfRowsPerPageOptions(rowCount, undefined, paginationState.pageSize), [rowCount, paginationState.pageSize]);
20
- return (_jsxs(Flex, { className: styles.toolbar, bg: "var(--ad-color-bg-subtle)", px: "md", py: "xshalf", justify: "space-between", align: "center", children: [_jsxs(Flex, { align: "center", gap: "sm", w: "fit-content", flex: "none", children: [_jsx(Text, { size: "xs", children: translate("table.rows.per.page") }), _jsx(Box, { w: PAGE_SIZE_SELECT_WIDTH, className: styles.pageSize, children: _jsx(Select, { disabled: !rowCount || isDisabled, "aria-label": translate("table.rows.per.page"), data: numOfRowsPerPageOptions, value: paginationState.pageSize.toString(), onChange: onPageSizeChangeHandler, size: "xs", w: "100%", rightSectionWidth: 22, variant: "unstyled", comboboxProps: { withinPortal: false, width: "max-content" } }) })] }), numberOfSelectedRowsText && _jsx(Text, { size: "xs", children: numberOfSelectedRowsText }), _jsxs(Flex, { align: "center", gap: "xs", children: [_jsx(Text, { size: "xs", children: formattedPageLegend }), _jsx(ActionIcon, { "data-testid": "previous-page-btn", disabled: !hasPreviousPage || isDisabled, onClick: () => {
21
+ return (_jsxs(Flex, { className: styles.toolbar, bg: "var(--ad-color-bg-subtle)", px: "md", py: "xshalf", justify: "space-between", align: "center", children: [_jsxs(Flex, { align: "center", gap: "sm", w: "fit-content", flex: "none", children: [_jsx(Text, { size: "xs", children: translate("table.rows.per.page") }), _jsx(Box, { w: PAGE_SIZE_SELECT_WIDTH, className: styles.pageSize, children: _jsx(Select, { disabled: !rowCount || isDisabled, "aria-label": translate("table.rows.per.page"), data: numOfRowsPerPageOptions, value: paginationState.pageSize.toString(), onChange: onPageSizeChangeHandler, size: "xs", w: "100%", rightSectionWidth: 22, variant: "unstyled", rightSection: _jsx(DropdownIcon, { className: styles.pageSizeChevron }), classNames: { input: styles.pageSizeInput, section: styles.pageSizeSection }, comboboxProps: { withinPortal: false, width: "max-content" } }) })] }), numberOfSelectedRowsText && _jsx(Text, { size: "xs", children: numberOfSelectedRowsText }), _jsxs(Flex, { align: "center", gap: "xs", children: [_jsx(Text, { size: "xs", children: formattedPageLegend }), _jsx(ActionIcon, { "data-testid": "previous-page-btn", disabled: !hasPreviousPage || isDisabled, onClick: () => {
21
22
  if (!isFetching && onPreviousPage) {
22
23
  onPreviousPage();
23
24
  }
@@ -4,6 +4,7 @@ import React, { useMemo, ReactElement } from "react";
4
4
  import { Box, Flex, Select, ActionIcon, Text } from "@mantine/core";
5
5
  import { RiArrowLeftSLine as PreviousPageIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
6
6
  import { RiArrowRightSLine as NextPageIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
7
+ import { RiArrowDropDownFill as DropdownIcon } from "@remixicon/react"; // DS-ADAPT: down triangle for the page-size select
7
8
  import { PaginationState } from "../types";
8
9
  import { translate } from "../translations"; // DS-ADAPT: translate lives in DataTable/translations
9
10
  import { getFormattedPageCount, getFormattedPageSize, getNumOfRowsPerPageOptions } from "./utils";
@@ -76,6 +77,8 @@ const CustomBottomToolbar = ({
76
77
  w="100%"
77
78
  rightSectionWidth={22}
78
79
  variant="unstyled"
80
+ rightSection={<DropdownIcon className={styles.pageSizeChevron} />} // DS-ADAPT: down triangle marks the select as interactive
81
+ classNames={{ input: styles.pageSizeInput, section: styles.pageSizeSection }} // DS-ADAPT: chevron, no fill or border
79
82
  comboboxProps={{ withinPortal: false, width: "max-content" }}
80
83
  />
81
84
  </Box>
@@ -1,4 +1,12 @@
1
- .action {
1
+ /* The global outline Button rule paints brand blue on the brand-blue banner, which made the action
2
+ invisible. These selectors match its :hover / :active specificity so the banner colours win
3
+ without !important. */
4
+ .action[data-variant="outline"]:not(:disabled):not([data-disabled]) {
2
5
  color: var(--ad-table-toolbar-selection-banner-fg);
3
6
  border-color: var(--ad-table-toolbar-selection-banner-fg);
4
7
  }
8
+
9
+ .action.action[data-variant="outline"]:not(:disabled):not([data-disabled]):hover,
10
+ .action.action[data-variant="outline"]:not(:disabled):not([data-disabled]):active {
11
+ background: color-mix(in srgb, var(--ad-table-toolbar-selection-banner-fg) 16%, transparent);
12
+ }
@@ -2,6 +2,13 @@
2
2
  border-bottom: var(--ad-table-toolbar-border-width) solid var(--ad-table-toolbar-border-color);
3
3
  }
4
4
 
5
+ /* Closed: same white-surface outline as the fullscreen and density buttons (outline variant).
6
+ Open: brand outline and icon, matching the outline Button. */
7
+ .filterToggle[data-open="true"][data-variant] {
8
+ color: var(--ad-color-brand-primary);
9
+ border-color: var(--ad-color-brand-primary);
10
+ }
11
+
5
12
  .clearFilters {
6
13
  cursor: pointer;
7
14
  }
@@ -1,3 +1,10 @@
1
1
  .field label {
2
2
  font-weight: 600;
3
3
  }
4
+
5
+ /* The trigger is a <button>, so unlike a text input it does not centre its text vertically:
6
+ the global input padding plus the full-height line-height pushed the value below the City
7
+ select's text. Zero block padding lines the two up. */
8
+ .fieldInput[data-variant] {
9
+ padding-block: 0;
10
+ }