moi-computer 0.10.1-next.0 → 0.10.1-next.2

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 (49) hide show
  1. package/client/app/shell/SidebarLayout.tsx +3 -3
  2. package/client/components/shared/AgentBlobatar.tsx +93 -0
  3. package/client/features/chat/ChatEmptyState.tsx +122 -77
  4. package/client/features/chat/ChatPanel.tsx +22 -11
  5. package/client/features/chat/ChatPopup.tsx +23 -11
  6. package/client/features/chat/ChatPromptBubbles.tsx +1 -1
  7. package/client/features/chat/TurnView.tsx +0 -17
  8. package/client/features/chat/useChat.ts +10 -2
  9. package/client/features/chat/useStickToBottom.ts +1 -1
  10. package/client/features/dev/ChatStatesPage.tsx +17 -9
  11. package/client/features/workspace/CustomizePanel.tsx +33 -4
  12. package/client/features/workspace/WorkspaceScreen.tsx +17 -7
  13. package/client/features/workspace/WorkspaceTabs.tsx +5 -8
  14. package/client/index.css +22 -12
  15. package/client/index.tsx +1 -0
  16. package/client/theme.css +9 -0
  17. package/dist/{chunk-efdyz6xp.js → chunk-0pcdwjkp.js} +1 -1
  18. package/dist/chunk-4xmcsjjv.js +1 -0
  19. package/dist/{chunk-5t06zksf.js → chunk-8jh75pjg.js} +2 -2
  20. package/dist/{chunk-97eg9mjn.js → chunk-9y2zbzqz.js} +1 -1
  21. package/dist/chunk-dfs36zgc.js +1 -0
  22. package/dist/chunk-e4e993yf.js +83 -0
  23. package/dist/chunk-ek8w9tsp.css +1 -0
  24. package/dist/chunk-vq8ga42s.js +1 -0
  25. package/dist/{chunk-ht1f95h9.js → chunk-yhj9bg1s.js} +2 -2
  26. package/dist/{chunk-0set7tmf.js → chunk-yt2qjn3m.js} +2 -2
  27. package/dist/chunk-yz743a75.js +10 -0
  28. package/dist/index.html +1 -1
  29. package/lib/themes.ts +21 -3
  30. package/lib/types.ts +1 -1
  31. package/package.json +4 -2
  32. package/server/bundler/build-applet.ts +30 -0
  33. package/server/cli-ui-components.ts +258 -0
  34. package/server/cli.ts +48 -5
  35. package/server/control.ts +5 -3
  36. package/server/moi-scaffold.ts +9 -1
  37. package/server/skills-template.ts +5 -0
  38. package/server/theme.ts +17 -5
  39. package/server/ui-components.ts +545 -0
  40. package/workspace/.claude/skills/moi-workspace/SKILL.md +27 -6
  41. package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +10 -2
  42. package/workspace/.claude/skills/moi-workspace/references/UI-COMPONENTS.md +211 -0
  43. package/client/components/shared/IconGhost.tsx +0 -127
  44. package/dist/chunk-4057kxht.css +0 -1
  45. package/dist/chunk-b5c62p8h.js +0 -1
  46. package/dist/chunk-dfe7qnrp.js +0 -1
  47. package/dist/chunk-f6xmz3tn.js +0 -83
  48. package/dist/chunk-h2kj1ysj.js +0 -1
  49. package/dist/chunk-qtc5a8qa.js +0 -10
@@ -0,0 +1,545 @@
1
+ // The `moi ui-components` engine: a shadcn-lite proxy over the `shadcn`
2
+ // package's own programmatic registry + transform APIs (see docs/moi-shadcn.md
3
+ // for the full spec and the research trail in PR #78).
4
+ //
5
+ // Opinions, enforced here: the upstream registry is the source of truth
6
+ // (style `base-nova`, Base UI primitives, Tabler icons); the command exposes
7
+ // only a curated subset of it; no config files ever land in the workspace —
8
+ // the engine takes its config as the in-memory object below; components are
9
+ // written to `.moi/ui/` and imported relatively (`../ui/button`). The command
10
+ // writes source files and nothing else: it never installs dependencies and
11
+ // never rebuilds — it prints next steps for the agent instead.
12
+ // `shadcn/registry`, `shadcn/utils` and `ts-morph` are imported at their call
13
+ // sites rather than here, deliberately. Together they are ~31 MB of JS across
14
+ // 1600 modules (ts-morph alone embeds the whole TypeScript compiler), and the
15
+ // cost is parse + top-level evaluation, so bundling does not help — measured
16
+ // at ~300 ms. Only `moi ui-components add` ever fetches or transforms; a
17
+ // static import here made every `moi` command pay it, `moi version` included.
18
+ import type { Project, SourceFile } from 'ts-morph'
19
+ import { join } from 'path'
20
+
21
+ // ---------------------------------------------------------------------------
22
+ // The curated catalog
23
+ // ---------------------------------------------------------------------------
24
+
25
+ export type UiComponentEntry = {
26
+ // One line for `moi ui-components list` and the skill cheat sheet.
27
+ description: string
28
+ // Registry items `add` actually fetches. Most entries map to themselves;
29
+ // pattern entries (data-table, date-picker) map to their building blocks
30
+ // and exist upstream only as docs.
31
+ registryItems: string[]
32
+ // npm packages the entry needs that no fetched registry item declares —
33
+ // pattern-only additions their docs assume (data-table → TanStack Table).
34
+ // Everything else flows from the resolved items' own `dependencies`.
35
+ extraDeps?: string[]
36
+ // Docs slug when it differs from the entry name (none currently).
37
+ docsSlug?: string
38
+ }
39
+
40
+ // The agreed subset (UI component review, Aug 2026). Upstream ships ~63 ui
41
+ // items; only these are exposed. Registry dependencies of a curated item
42
+ // (e.g. field → label + separator, chart → card, toggle-group → toggle) are
43
+ // resolved and written implicitly — they are support files, not catalog
44
+ // entries.
45
+ export const UI_COMPONENTS: Record<string, UiComponentEntry> = {
46
+ accordion: {
47
+ description: 'Vertically stacked sections that expand one at a time',
48
+ registryItems: ['accordion']
49
+ },
50
+ alert: {
51
+ description: 'Callout box for statuses and short messages',
52
+ registryItems: ['alert']
53
+ },
54
+ 'alert-dialog': {
55
+ description: 'Modal confirmation dialog for destructive or blocking actions',
56
+ registryItems: ['alert-dialog']
57
+ },
58
+ attachment: {
59
+ description: 'File or image attachment tile with metadata and actions',
60
+ registryItems: ['attachment']
61
+ },
62
+ avatar: {
63
+ description: 'User or entity image with fallback initials',
64
+ registryItems: ['avatar']
65
+ },
66
+ badge: {
67
+ description: 'Small status or count label',
68
+ registryItems: ['badge']
69
+ },
70
+ bubble: {
71
+ description: 'Chat message bubble',
72
+ registryItems: ['bubble']
73
+ },
74
+ button: {
75
+ description: 'The button: variants, sizes, icon support',
76
+ registryItems: ['button']
77
+ },
78
+ 'button-group': {
79
+ description: 'Buttons joined into one segmented control',
80
+ registryItems: ['button-group']
81
+ },
82
+ calendar: {
83
+ description: 'Month calendar for picking dates and ranges',
84
+ registryItems: ['calendar']
85
+ },
86
+ carousel: {
87
+ description: 'Swipeable slides with prev/next controls',
88
+ registryItems: ['carousel']
89
+ },
90
+ chart: {
91
+ description: 'Recharts-based charts wired to workspace theme tokens',
92
+ registryItems: ['chart']
93
+ },
94
+ checkbox: {
95
+ description: 'Binary checkbox with indeterminate state',
96
+ registryItems: ['checkbox']
97
+ },
98
+ collapsible: {
99
+ description: 'Single section that expands and collapses',
100
+ registryItems: ['collapsible']
101
+ },
102
+ combobox: {
103
+ description: 'Text input with a filtered dropdown of options',
104
+ registryItems: ['combobox']
105
+ },
106
+ 'context-menu': {
107
+ description: 'Right-click menu with items, submenus, and shortcuts',
108
+ registryItems: ['context-menu']
109
+ },
110
+ 'data-table': {
111
+ description: 'Sortable, filterable table pattern built on table + TanStack Table',
112
+ registryItems: ['table'],
113
+ extraDeps: ['@tanstack/react-table']
114
+ },
115
+ 'date-picker': {
116
+ description: 'Date picker pattern: calendar in a popover',
117
+ registryItems: ['calendar', 'popover', 'button']
118
+ },
119
+ dialog: {
120
+ description: 'Modal dialog with backdrop, header, and footer',
121
+ registryItems: ['dialog']
122
+ },
123
+ 'dropdown-menu': {
124
+ description: 'Menu opened from a trigger: items, groups, submenus',
125
+ registryItems: ['dropdown-menu']
126
+ },
127
+ field: {
128
+ description: 'Form field wrapper: label, control, description, error',
129
+ registryItems: ['field']
130
+ },
131
+ 'hover-card': {
132
+ description: 'Preview card shown on hover over a link or element',
133
+ registryItems: ['hover-card']
134
+ },
135
+ input: {
136
+ description: 'Single-line text input',
137
+ registryItems: ['input']
138
+ },
139
+ 'input-group': {
140
+ description: 'Input with attached addons, buttons, or icons',
141
+ registryItems: ['input-group']
142
+ },
143
+ label: {
144
+ description: 'Form control label',
145
+ registryItems: ['label']
146
+ },
147
+ pagination: {
148
+ description: 'Page navigation with prev/next and page links',
149
+ registryItems: ['pagination']
150
+ },
151
+ popover: {
152
+ description: 'Floating panel anchored to a trigger',
153
+ registryItems: ['popover']
154
+ },
155
+ progress: {
156
+ description: 'Determinate progress bar',
157
+ registryItems: ['progress']
158
+ },
159
+ 'radio-group': {
160
+ description: 'Single-choice radio button set',
161
+ registryItems: ['radio-group']
162
+ },
163
+ resizable: {
164
+ description: 'Resizable split panels with drag handles',
165
+ registryItems: ['resizable']
166
+ },
167
+ select: {
168
+ description: 'Native-feeling select with a styled popup',
169
+ registryItems: ['select']
170
+ },
171
+ skeleton: {
172
+ description: 'Loading placeholder block',
173
+ registryItems: ['skeleton']
174
+ },
175
+ slider: {
176
+ description: 'Range slider with one or more thumbs',
177
+ registryItems: ['slider']
178
+ },
179
+ spinner: {
180
+ description: 'Inline loading spinner',
181
+ registryItems: ['spinner']
182
+ },
183
+ switch: {
184
+ description: 'On/off toggle switch',
185
+ registryItems: ['switch']
186
+ },
187
+ table: {
188
+ description: 'Styled table primitives (header, body, rows, cells)',
189
+ registryItems: ['table']
190
+ },
191
+ tabs: {
192
+ description: 'Tabbed panels with a tab list',
193
+ registryItems: ['tabs']
194
+ },
195
+ textarea: {
196
+ description: 'Multi-line text input',
197
+ registryItems: ['textarea']
198
+ },
199
+ 'toggle-group': {
200
+ description: 'Group of two-state toggle buttons',
201
+ registryItems: ['toggle-group']
202
+ },
203
+ tooltip: {
204
+ description: 'Small label shown on hover or focus',
205
+ registryItems: ['tooltip']
206
+ }
207
+ }
208
+
209
+ export const UI_COMPONENT_NAMES = Object.keys(UI_COMPONENTS)
210
+
211
+ // ---------------------------------------------------------------------------
212
+ // Engine config — the in-memory replacement for components.json
213
+ // ---------------------------------------------------------------------------
214
+
215
+ // The whole point of driving the engine programmatically: this object stays
216
+ // inside moi and the workspace never grows a components.json or tsconfig.
217
+ // Aliases are placeholders the engine requires but never applies — raw
218
+ // registry content hardcodes `@/registry/<style>/…` specifiers, which
219
+ // rewriteRegistryImports below maps to relative paths.
220
+ // Cast once to `never`: the engine functions accept `Partial<Config>`, but
221
+ // shadcn exports no public name for that resolved Config type (only the
222
+ // components.json shape) — `never` is assignable to every parameter type, and
223
+ // nothing here reads the constant back.
224
+ const ENGINE_CONFIG = {
225
+ style: 'base-nova',
226
+ tailwind: { css: 'unused.css', baseColor: 'neutral', cssVariables: true },
227
+ rsc: false,
228
+ tsx: true,
229
+ iconLibrary: 'tabler',
230
+ rtl: false,
231
+ aliases: { ui: '@/components/ui', utils: '@/lib/utils' }
232
+ } as never
233
+
234
+ export const UI_DOCS_BASE = 'https://ui.shadcn.com/docs/components/base'
235
+
236
+ // ---------------------------------------------------------------------------
237
+ // Fetching
238
+ // ---------------------------------------------------------------------------
239
+
240
+ export type FetchedUiFile = {
241
+ // File name inside `.moi/ui/` (`button.tsx`, `utils.ts`).
242
+ name: string
243
+ content: string
244
+ }
245
+
246
+ export type FetchedUiComponents = {
247
+ files: FetchedUiFile[]
248
+ // npm dependencies declared by the resolved registry items (versioned
249
+ // specifiers like `recharts@3.8.0` pass through as-is).
250
+ dependencies: string[]
251
+ }
252
+
253
+ // Where a registry file lands in `.moi/ui/`. Registry paths look like
254
+ // `registry/base-nova/ui/button.tsx`, `registry/base-nova/lib/utils.ts`,
255
+ // `registry/base-nova/hooks/use-mobile.ts` — everything flattens into the one
256
+ // ui dir so relative imports stay `./<name>`.
257
+ function uiFileName(registryPath: string): string {
258
+ const base = registryPath.split('/').pop() ?? registryPath
259
+ return base
260
+ }
261
+
262
+ // Fetch the requested registry items plus their registryDependencies, closed
263
+ // transitively, deduplicated. `utils` (the `cn` helper) rides along on every
264
+ // fetch — it is the one support file everything imports.
265
+ export async function fetchUiComponents(registryNames: string[]): Promise<FetchedUiComponents> {
266
+ const files = new Map<string, string>()
267
+ const dependencies = new Set<string>()
268
+ const fetched = new Set<string>()
269
+ let queue = [...new Set(['utils', ...registryNames])]
270
+
271
+ const { getRegistryItems } = await import('shadcn/registry')
272
+
273
+ while (queue.length > 0) {
274
+ const batch = queue.filter(name => !fetched.has(name))
275
+ if (batch.length === 0) break
276
+ for (const name of batch) fetched.add(name)
277
+
278
+ const items = await getRegistryItems(batch, { config: ENGINE_CONFIG })
279
+ const next: string[] = []
280
+ for (const item of items ?? []) {
281
+ for (const dep of item.dependencies ?? []) dependencies.add(dep)
282
+ for (const dep of item.registryDependencies ?? []) {
283
+ // Registry deps are plain item names for the shadcn registry; URLs
284
+ // would point at third-party registries, which the curated set never
285
+ // references.
286
+ if (!fetched.has(dep)) next.push(dep)
287
+ }
288
+ for (const file of item.files ?? []) {
289
+ if (!file.content) continue
290
+ files.set(uiFileName(file.path), file.content)
291
+ }
292
+ }
293
+ queue = next
294
+ }
295
+
296
+ return {
297
+ files: [...files.entries()].map(([name, content]) => ({ name, content })),
298
+ dependencies: [...dependencies].sort()
299
+ }
300
+ }
301
+
302
+ // ---------------------------------------------------------------------------
303
+ // Transforms
304
+ // ---------------------------------------------------------------------------
305
+
306
+ // Rewrite `@/registry/<style>/{lib,ui,hooks}/<x>` specifiers to sibling-relative
307
+ // paths. There is no engine knob for this: aliases are validated against
308
+ // tsconfig paths, so a relative alias value is rejected outright (verified —
309
+ // see docs/moi-shadcn.md). Walks import AND export declarations on the same
310
+ // ts-morph SourceFile the icon transform used, so re-exports are covered.
311
+ function rewriteRegistryImports(sourceFile: SourceFile): void {
312
+ const rewrite = (spec: string): string | null => {
313
+ const match = /^@\/registry\/[^/]+\/(?:lib|ui|hooks)\/([\w-]+)$/.exec(spec)
314
+ return match ? `./${match[1]}` : null
315
+ }
316
+ for (const decl of sourceFile.getImportDeclarations()) {
317
+ const next = rewrite(decl.getModuleSpecifierValue())
318
+ if (next) decl.setModuleSpecifier(next)
319
+ }
320
+ for (const decl of sourceFile.getExportDeclarations()) {
321
+ const spec = decl.getModuleSpecifierValue()
322
+ if (!spec) continue
323
+ const next = rewrite(spec)
324
+ if (next) decl.setModuleSpecifier(next)
325
+ }
326
+ }
327
+
328
+ // The portal codemod. Base UI overlays portal into document.body — outside
329
+ // the applet container, so the applet's scoped styles ([data-applet="…"] …,
330
+ // see server/bundler/applet-css.ts) stop matching and overlays render on
331
+ // accidentally borrowed host styles. Overlays should keep portalling to body
332
+ // (escaping the widget frame's overflow/stacking is the point) — so instead
333
+ // of re-containering them, every `<X.Portal …>` JSX element is rewritten to
334
+ // `<AppletPortal portal={X.Portal} …>`, a wrapper (installed as
335
+ // `ui/applet-portal.tsx`) that re-establishes the scope attribute on the
336
+ // portalled subtree. Type positions (`X.Portal.Props`) are untouched — the
337
+ // rewrite only sees JSX tag names.
338
+ // `SyntaxKind` is passed in rather than imported: ts-morph is loaded lazily by
339
+ // the one caller below, so this helper cannot close over a module-level import.
340
+ function rewritePortals(
341
+ sourceFile: SourceFile,
342
+ SyntaxKind: typeof import('ts-morph').SyntaxKind
343
+ ): boolean {
344
+ const PORTAL_TAG = /^[A-Za-z_$][\w$]*\.Portal$/
345
+ let touched = false
346
+
347
+ for (const el of sourceFile.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement)) {
348
+ if (!PORTAL_TAG.test(el.getTagNameNode().getText())) continue
349
+ const portalExpr = el.getTagNameNode().getText()
350
+ el.getTagNameNode().replaceWithText('AppletPortal')
351
+ el.insertAttribute(0, { name: 'portal', initializer: `{${portalExpr}}` })
352
+ touched = true
353
+ }
354
+ for (const el of sourceFile.getDescendantsOfKind(SyntaxKind.JsxElement)) {
355
+ const opening = el.getOpeningElement()
356
+ if (!PORTAL_TAG.test(opening.getTagNameNode().getText())) continue
357
+ const portalExpr = opening.getTagNameNode().getText()
358
+ opening.getTagNameNode().replaceWithText('AppletPortal')
359
+ el.getClosingElement().getTagNameNode().replaceWithText('AppletPortal')
360
+ opening.insertAttribute(0, { name: 'portal', initializer: `{${portalExpr}}` })
361
+ touched = true
362
+ }
363
+
364
+ if (touched) {
365
+ sourceFile.addImportDeclaration({
366
+ moduleSpecifier: './applet-portal',
367
+ namedImports: [{ name: 'AppletPortal' }]
368
+ })
369
+ }
370
+ return touched
371
+ }
372
+
373
+ // One shared ts-morph project for all transforms in a process — creating a
374
+ // Project per file re-parses lib.d.ts and dominates runtime.
375
+ let project: Project | undefined
376
+
377
+ // Apply moi's transform pipeline to one raw registry file: shadcn's own icon
378
+ // transform (IconPlaceholder → @tabler/icons-react) and menu transform
379
+ // (cn-menu-* classes for the default menu color), then the relative-import
380
+ // rewrite and the portal codemod.
381
+ export async function transformUiComponentSource(name: string, raw: string): Promise<string> {
382
+ const { Project, ScriptKind, SyntaxKind } = await import('ts-morph')
383
+ const { transformIcons, transformMenu } = await import('shadcn/utils')
384
+
385
+ project ??= new Project({ useInMemoryFileSystem: true })
386
+ const sourceFile = project.createSourceFile(`moi-ui/${name}`, raw, {
387
+ scriptKind: name.endsWith('.tsx') ? ScriptKind.TSX : ScriptKind.TS,
388
+ overwrite: true
389
+ })
390
+ const opts = { sourceFile, filename: name, raw, config: ENGINE_CONFIG }
391
+ await transformIcons(opts)
392
+ await transformMenu(opts)
393
+ rewriteRegistryImports(sourceFile)
394
+ rewritePortals(sourceFile, SyntaxKind)
395
+ return sourceFile.getFullText()
396
+ }
397
+
398
+ // ---------------------------------------------------------------------------
399
+ // The AppletPortal helper — installed once as `ui/applet-portal.tsx`
400
+ // ---------------------------------------------------------------------------
401
+
402
+ // Embedded as a string like the other scaffold templates (see
403
+ // moi-scaffold.ts): the file belongs to the workspace, not to moi's bundle.
404
+ // The hidden marker renders where the overlay is used — inside the applet's
405
+ // DOM — and reads the nearest `data-applet` scope; the portalled children
406
+ // then render under an element carrying the same attribute, so the applet's
407
+ // scoped CSS matches again. `display: contents` keeps the wrapper out of
408
+ // layout; theme variables still resolve from the host `:root`.
409
+ //
410
+ // The file header below is written for its actual reader — the workspace
411
+ // agent browsing `.moi/ui/` — so it stays non-technical: what the file is
412
+ // for, that it's auto-generated, and that it must be left alone. The
413
+ // mechanism belongs here, not there.
414
+ export const APPLET_PORTAL_SOURCE = `"use client"
415
+
416
+ // Auto-generated by \`moi ui-components add\` — do not edit or remove.
417
+ //
418
+ // Keeps overlays (dialogs, menus, popovers, tooltips) styled correctly when
419
+ // they render outside the applet's own container. Components in this folder
420
+ // use it automatically; you never import it yourself.
421
+ import * as React from "react"
422
+
423
+ type AppletPortalProps = {
424
+ portal: React.ElementType
425
+ children?: React.ReactNode
426
+ } & Record<string, unknown>
427
+
428
+ function AppletPortal({ portal: Portal, children, ...props }: AppletPortalProps) {
429
+ const [scope, setScope] = React.useState<string | undefined>(undefined)
430
+ const marker = React.useCallback((node: HTMLElement | null) => {
431
+ if (node) {
432
+ setScope(node.closest("[data-applet]")?.getAttribute("data-applet") ?? undefined)
433
+ }
434
+ }, [])
435
+ return (
436
+ <>
437
+ <span hidden ref={marker} />
438
+ <Portal {...props}>
439
+ <div data-applet={scope} style={{ display: "contents" }}>
440
+ {children}
441
+ </div>
442
+ </Portal>
443
+ </>
444
+ )
445
+ }
446
+
447
+ export { AppletPortal }
448
+ `
449
+
450
+ // ---------------------------------------------------------------------------
451
+ // Name resolution + write planning (pure — covered by tests)
452
+ // ---------------------------------------------------------------------------
453
+
454
+ export type ResolvedRequest = {
455
+ // Curated entries requested, validated.
456
+ entries: string[]
457
+ // Registry items to fetch (patterns expanded), deduplicated, in request order.
458
+ registryItems: string[]
459
+ // Union of extraDeps across the requested entries.
460
+ extraDeps: string[]
461
+ unknown: string[]
462
+ }
463
+
464
+ export function resolveUiComponentRequest(names: string[]): ResolvedRequest {
465
+ const entries: string[] = []
466
+ const registryItems: string[] = []
467
+ const extraDeps = new Set<string>()
468
+ const unknown: string[] = []
469
+
470
+ for (const raw of names) {
471
+ const name = raw.toLowerCase()
472
+ const entry = UI_COMPONENTS[name]
473
+ if (!entry) {
474
+ unknown.push(raw)
475
+ continue
476
+ }
477
+ if (!entries.includes(name)) entries.push(name)
478
+ for (const item of entry.registryItems) {
479
+ if (!registryItems.includes(item)) registryItems.push(item)
480
+ }
481
+ for (const dep of entry.extraDeps ?? []) extraDeps.add(dep)
482
+ }
483
+
484
+ return { entries, registryItems, extraDeps: [...extraDeps].sort(), unknown }
485
+ }
486
+
487
+ // Closest catalog names for a typo, by shared-prefix + substring heuristics —
488
+ // enough for `alert-dialog` vs `alertdialog` and singular/plural slips.
489
+ export function suggestUiComponents(name: string, limit = 3): string[] {
490
+ const needle = name.toLowerCase().replace(/[^a-z0-9]/g, '')
491
+ const scored = UI_COMPONENT_NAMES.map(candidate => {
492
+ const flat = candidate.replace(/[^a-z0-9]/g, '')
493
+ let score = 0
494
+ if (flat === needle) score = 100
495
+ else if (flat.startsWith(needle) || needle.startsWith(flat)) score = 80
496
+ else if (flat.includes(needle) || needle.includes(flat)) score = 60
497
+ else {
498
+ let common = 0
499
+ while (common < Math.min(flat.length, needle.length) && flat[common] === needle[common]) {
500
+ common++
501
+ }
502
+ score = common >= 3 ? common * 10 : 0
503
+ }
504
+ return { candidate, score }
505
+ })
506
+ return scored
507
+ .filter(s => s.score > 0)
508
+ .sort((a, b) => b.score - a.score)
509
+ .slice(0, limit)
510
+ .map(s => s.candidate)
511
+ }
512
+
513
+ export type PlannedWrite = {
514
+ name: string
515
+ path: string
516
+ content: string
517
+ // Whether a file already exists at the target path.
518
+ exists: boolean
519
+ // Support files ride along with a request (utils, applet-portal, registry
520
+ // deps of a requested component). Existing support files are never
521
+ // overwritten — they may carry hand customizations; existing requested
522
+ // files fail the add unless --force.
523
+ support: boolean
524
+ }
525
+
526
+ export function planUiWrites(opts: {
527
+ files: FetchedUiFile[]
528
+ requestedItems: string[]
529
+ uiDir: string
530
+ exists: (path: string) => boolean
531
+ }): PlannedWrite[] {
532
+ const requested = new Set(opts.requestedItems.map(item => `${item}.tsx`))
533
+ const plans: PlannedWrite[] = [
534
+ ...opts.files.map(file => ({
535
+ name: file.name,
536
+ content: file.content,
537
+ support: !requested.has(file.name)
538
+ })),
539
+ { name: 'applet-portal.tsx', content: APPLET_PORTAL_SOURCE, support: true }
540
+ ].map(file => {
541
+ const path = join(opts.uiDir, file.name)
542
+ return { ...file, path, exists: opts.exists(path) }
543
+ })
544
+ return plans
545
+ }
@@ -182,8 +182,9 @@ from `.moi/package.json` deps — no `@/` aliases. Files starting with `_` (e.g.
182
182
  per-frame transforms.
183
183
  - Use icons from `@tabler/icons-react`. Do not add raw SVG icons or another icon pack. When the
184
184
  project provides `.agents/rules/icons.md`, follow its size and stroke policy.
185
- - Applets cannot import the host project's `cn`. Use a local `cx()` when classes are conditional;
186
- do not build class names with template-literal ternaries.
185
+ - Applets cannot import the host project's `cn`. If `.moi/ui/utils.ts` exists, import `cn` from
186
+ `../ui/utils`; otherwise use a local `cx()` when classes are conditional. Never build class
187
+ names with template-literal ternaries.
187
188
 
188
189
  ```tsx
189
190
  function cx(...classes: (string | false | undefined | null)[]) {
@@ -191,6 +192,26 @@ function cx(...classes: (string | false | undefined | null)[]) {
191
192
  }
192
193
  ```
193
194
 
195
+ ## Standard UI components
196
+
197
+ Need a standard control (button, dialog, select, table, chart…)? Don't hand-roll it —
198
+ `moi ui-components add <name>` installs a moi-tuned shadcn component (Base UI + Tabler icons,
199
+ workspace theme tokens, overlays patched to keep applet styling) into `.moi/ui/`. Import
200
+ relatively: `import { Button } from '../ui/button'`.
201
+
202
+ - `moi ui-components` — the catalog with installed state. Read
203
+ `references/UI-COMPONENTS.md` first: the full catalog plus the essential usage rules
204
+ (Base UI composition, forms, styling, icons — condensed from the official shadcn skill).
205
+ - `moi ui-components docs <name>` — full official docs (markdown: anatomy, props, examples) on
206
+ demand. Read them before composing an unfamiliar component; the parts API (Base UI) differs
207
+ from Radix-era shadcn.
208
+ - `add` never installs npm packages or rebuilds — it prints the deps it needs; install them in
209
+ `.moi/` and run `moi bundle` yourself.
210
+ - Files in `.moi/ui/` are yours to customize (edits propagate to every applet using them);
211
+ re-running `add` refuses to overwrite them without `--force`.
212
+ - Component names, their API, and the CLI are very close to a selected subset of shadcn, but the
213
+ actual implementation might differ.
214
+
194
215
  ## Server functions — `<name>.server.ts`
195
216
 
196
217
  Export named `async function`s (only — no `const`, sync, or class) and call them from the component
@@ -412,10 +433,10 @@ This skill is installed with moi (via the CLI or the UI) and can fall behind whe
412
433
 
413
434
  - **You'll know** — `moi` commands warn you when this skill is behind.
414
435
  - **To update** — run `moi skill update`. Never mid-task: finish first, or do it at the end.
415
- - **Re-read after updating** — `moi skill update` rewrites `SKILL.md` and its companion docs
416
- (`references/DESIGN.md` and `references/SCRATCHPAD.md`) on disk, so the copy already in your context is stale. Re-read
417
- this `SKILL.md` before you rely on it again — don't act on the old version.
436
+ - **Re-read after updating** — `moi skill update` rewrites `SKILL.md` and everything in
437
+ `references/` on disk, so the copy already in your context is stale. Re-read this `SKILL.md`
438
+ before you rely on it again — don't act on the old version.
418
439
  - **Then** — if you updated, mention it.
419
440
 
420
441
  <!-- moi skill version marker — read by `moi skill` to detect drift; do not edit by hand -->
421
- <moi-skill version="0.13.0" />
442
+ <moi-skill version="0.15.0" />
@@ -97,7 +97,7 @@ controls, or text regions, stack textures, or add tuning variables. Check nearby
97
97
  applets use different textures, while a widget representing a view shares its texture. Any texture
98
98
  should become easy to ignore while reading.
99
99
 
100
- ### Type, spacing, and shape
100
+ ### Type
101
101
 
102
102
  Inherit the workspace font and use sentence case. Use regular weight for most text and medium for
103
103
  emphasis; other weights are reserved for owner hand-tuning. `text-sm` (14 px) is the UI default.
@@ -108,12 +108,20 @@ Reserve `font-mono` for code, commands, and code-like identifiers. Numeric value
108
108
  percentages, timers, timestamps, prices, counts, and labels use the workspace font. Add
109
109
  `tabular-nums` when stable widths or alignment help.
110
110
 
111
+ ### Icons
112
+
113
+ Set `stroke` explicitly on every Tabler icon; the package default of `2` is heavier than the
114
+ workspace chrome. Use `1.75` for 12–16 px icons and `1.5` for 20–24 px icons. When a component sets
115
+ the icon size, omit `size` and use the stroke that matches its rendered size.
116
+
117
+ ### Spacing and shape
118
+
111
119
  Follow a 4 px spacing rhythm: 4–8 px within a tight group, 12–16 px between groups in a region, and
112
120
  24 px or more at section changes in larger applets. Prefer spacing over dividers. Keep repeated
113
121
  rows, chart labels, status markers, counters, and trailing actions in stable lanes so changing
114
122
  values do not shift the layout.
115
123
 
116
- Use the shared shadcn radius scale and default control radii. Use `rounded-lg` or `rounded-xl` for
124
+ Use the shared radius scale and default control radii. Use `rounded-lg` or `rounded-xl` for
117
125
  ordinary regions, `rounded-2xl` or `rounded-3xl` for one focal surface, and `rounded-full` only for
118
126
  real pills, circles, avatars, and status dots. Rectangular controls must not become capsules.
119
127