moi-computer 0.10.1-next.1 → 0.10.1-next.3
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.
- package/client/components/shared/AgentBlobatar.tsx +93 -0
- package/client/features/chat/ChatEmptyState.tsx +110 -80
- package/client/features/chat/ChatPanel.tsx +19 -11
- package/client/features/chat/ChatPopup.tsx +23 -11
- package/client/features/chat/ChatPromptBubbles.tsx +1 -1
- package/client/features/chat/TurnView.tsx +0 -17
- package/client/features/chat/useStickToBottom.ts +1 -1
- package/client/features/dev/ChatStatesPage.tsx +17 -9
- package/client/features/workspace/CustomizePanel.tsx +33 -4
- package/client/features/workspace/WorkspaceScreen.tsx +11 -5
- package/client/features/workspace/WorkspaceTabs.tsx +5 -8
- package/client/index.css +28 -13
- package/client/index.html +15 -0
- package/client/index.tsx +1 -0
- package/client/theme.css +9 -0
- package/dist/{chunk-efdyz6xp.js → chunk-0pcdwjkp.js} +1 -1
- package/dist/chunk-4xmcsjjv.js +1 -0
- package/dist/chunk-76j95afs.css +1 -0
- package/dist/{chunk-5t06zksf.js → chunk-8jh75pjg.js} +2 -2
- package/dist/{chunk-97eg9mjn.js → chunk-9y2zbzqz.js} +1 -1
- package/dist/chunk-dfs36zgc.js +1 -0
- package/dist/chunk-e4e993yf.js +83 -0
- package/dist/chunk-vq8ga42s.js +1 -0
- package/dist/{chunk-ht1f95h9.js → chunk-yhj9bg1s.js} +2 -2
- package/dist/{chunk-0set7tmf.js → chunk-yt2qjn3m.js} +2 -2
- package/dist/chunk-yz743a75.js +10 -0
- package/dist/index.html +16 -1
- package/lib/themes.ts +21 -3
- package/lib/types.ts +1 -1
- package/package.json +4 -2
- package/server/bundler/build-applet.ts +30 -0
- package/server/cli-ui-components.ts +258 -0
- package/server/cli.ts +48 -5
- package/server/control.ts +5 -3
- package/server/moi-scaffold.ts +9 -1
- package/server/skills-template.ts +5 -0
- package/server/theme.ts +17 -5
- package/server/ui-components.ts +545 -0
- package/workspace/.claude/skills/moi-workspace/SKILL.md +27 -6
- package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +10 -2
- package/workspace/.claude/skills/moi-workspace/references/UI-COMPONENTS.md +202 -0
- package/client/components/shared/IconGhost.tsx +0 -127
- package/dist/chunk-10knptd0.css +0 -1
- package/dist/chunk-b4qp3p42.js +0 -83
- package/dist/chunk-dfe7qnrp.js +0 -1
- package/dist/chunk-h2kj1ysj.js +0 -1
- package/dist/chunk-nek4ec05.js +0 -1
- package/dist/chunk-qtc5a8qa.js +0 -10
package/dist/index.html
CHANGED
|
@@ -3,7 +3,22 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<!-- The app has no dark mode (nothing ever adds the `.dark` class), so say
|
|
7
|
+
so: without this the browser picks a base canvas from the OS setting. -->
|
|
8
|
+
<meta name="color-scheme" content="light" />
|
|
6
9
|
<title>moi</title>
|
|
10
|
+
<!-- First-paint background, inline and before the stylesheet link on
|
|
11
|
+
purpose. index.css is render-blocking, so until it resolves the browser
|
|
12
|
+
has only its own white canvas to paint — on a cold load or a new tab
|
|
13
|
+
that is a white flash the stylesheet cannot prevent, because it *is*
|
|
14
|
+
the stylesheet. Parsed from the HTML, this applies with no round trip.
|
|
15
|
+
The literal duplicates `--muted` in client/index.css (custom properties
|
|
16
|
+
do not exist yet at this point); theme.test.ts pins the two together. -->
|
|
17
|
+
<style>
|
|
18
|
+
html {
|
|
19
|
+
background: oklch(0.97 0 0);
|
|
20
|
+
}
|
|
21
|
+
</style>
|
|
7
22
|
<link rel="icon" type="image/png" href="/favicon-nbmyjfjh.png" />
|
|
8
23
|
<!-- React is vendored locally (client/vendor/react, generated by
|
|
9
24
|
scripts/build-vendor.ts) and served by the /vendor/react route, so moi
|
|
@@ -21,7 +36,7 @@
|
|
|
21
36
|
}
|
|
22
37
|
</script>
|
|
23
38
|
|
|
24
|
-
<link rel="stylesheet" crossorigin href="/chunk-
|
|
39
|
+
<link rel="stylesheet" crossorigin href="/chunk-76j95afs.css"><script type="module" crossorigin src="/chunk-vq8ga42s.js"></script></head>
|
|
25
40
|
<body>
|
|
26
41
|
<div id="root"></div>
|
|
27
42
|
|
package/lib/themes.ts
CHANGED
|
@@ -82,6 +82,20 @@ export const RADIUS_THEMES: Record<RadiusTheme, RadiusThemeConfig> = {
|
|
|
82
82
|
square: { label: 'Square', radius: '0' }
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
export type AgentTheme = 'round' | 'boxy' | 'capsule' | 'triangle'
|
|
86
|
+
|
|
87
|
+
export type AgentThemeConfig = {
|
|
88
|
+
label: string
|
|
89
|
+
shape: number
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export const AGENT_THEMES: Record<AgentTheme, AgentThemeConfig> = {
|
|
93
|
+
round: { label: 'Round', shape: 0.11 },
|
|
94
|
+
boxy: { label: 'Boxy', shape: 0.54 },
|
|
95
|
+
capsule: { label: 'Capsule', shape: 0.65 },
|
|
96
|
+
triangle: { label: 'Triangle', shape: 0.99 }
|
|
97
|
+
}
|
|
98
|
+
|
|
85
99
|
export type ColorTheme =
|
|
86
100
|
| 'default'
|
|
87
101
|
| 'paper'
|
|
@@ -110,7 +124,8 @@ const THEME_COLOR_DERIVATIONS = {
|
|
|
110
124
|
mutedForeground: () => 'color-mix(in srgb, var(--background) 50%, var(--foreground) 50%)',
|
|
111
125
|
accent: () => 'color-mix(in srgb, var(--primary) 4%, var(--foreground) 4%)',
|
|
112
126
|
accentForeground: () => 'var(--foreground)',
|
|
113
|
-
border: () => 'color-mix(in srgb, var(--foreground) 7%, transparent)'
|
|
127
|
+
border: () => 'color-mix(in srgb, var(--foreground) 7%, transparent)',
|
|
128
|
+
ring: () => 'color-mix(in srgb, var(--background) 50%, var(--primary) 50%)'
|
|
114
129
|
},
|
|
115
130
|
widget: {
|
|
116
131
|
background: primary => primary,
|
|
@@ -121,7 +136,8 @@ const THEME_COLOR_DERIVATIONS = {
|
|
|
121
136
|
mutedForeground: () => 'color-mix(in srgb, var(--background) 50%, var(--foreground) 50%)',
|
|
122
137
|
accent: () => 'color-mix(in srgb, var(--primary) 4%, var(--foreground) 4%)',
|
|
123
138
|
accentForeground: () => 'var(--foreground)',
|
|
124
|
-
border: () => 'color-mix(in srgb, var(--foreground) 15%, transparent)'
|
|
139
|
+
border: () => 'color-mix(in srgb, var(--foreground) 15%, transparent)',
|
|
140
|
+
ring: () => 'color-mix(in srgb, var(--background) 50%, var(--primary) 50%)'
|
|
125
141
|
}
|
|
126
142
|
} satisfies Record<ThemeColorMode, Record<string, (primary: string) => string>>
|
|
127
143
|
|
|
@@ -186,12 +202,14 @@ export type WorkspaceTheme = {
|
|
|
186
202
|
font: FontTheme
|
|
187
203
|
color: ColorTheme
|
|
188
204
|
radius: RadiusTheme
|
|
205
|
+
agent: AgentTheme
|
|
189
206
|
}
|
|
190
207
|
|
|
191
208
|
export const DEFAULT_WORKSPACE_THEME: WorkspaceTheme = {
|
|
192
209
|
font: 'sans',
|
|
193
210
|
color: 'default',
|
|
194
|
-
radius: 'soft'
|
|
211
|
+
radius: 'soft',
|
|
212
|
+
agent: 'boxy'
|
|
195
213
|
}
|
|
196
214
|
|
|
197
215
|
export function resolveWorkspaceTheme(theme?: Partial<WorkspaceTheme>): WorkspaceTheme {
|
package/lib/types.ts
CHANGED
|
@@ -540,7 +540,7 @@ export type WorkspaceTabsState = {
|
|
|
540
540
|
active: WorkspaceTabId
|
|
541
541
|
}
|
|
542
542
|
|
|
543
|
-
export type { ColorTheme, FontTheme, RadiusTheme, WorkspaceTheme } from './themes'
|
|
543
|
+
export type { AgentTheme, ColorTheme, FontTheme, RadiusTheme, WorkspaceTheme } from './themes'
|
|
544
544
|
|
|
545
545
|
export type WorkspaceLayout = {
|
|
546
546
|
version: 1
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "moi-computer",
|
|
3
|
-
"version": "0.10.1-next.
|
|
3
|
+
"version": "0.10.1-next.3",
|
|
4
4
|
"description": "Local AI workspace powered by the Claude Agent SDK, Bun, React, and Tailwind. Requires Bun.",
|
|
5
5
|
"license": "Elastic-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -60,11 +60,13 @@
|
|
|
60
60
|
"@anthropic-ai/sdk": "^0.109.1",
|
|
61
61
|
"@babel/parser": "^7.29.8",
|
|
62
62
|
"@base-ui/react": "^1.2.0",
|
|
63
|
+
"@blobatar/react": "^2.2.0",
|
|
63
64
|
"@dnd-kit/core": "^6.3.1",
|
|
64
65
|
"@tabler/icons-react": "^3.44.0",
|
|
65
66
|
"@tailwindcss/typography": "^0.5.19",
|
|
66
67
|
"@tanstack/react-query": "^5.100.1",
|
|
67
68
|
"agentation": "^2.3.3",
|
|
69
|
+
"blobatar": "^2.2.0",
|
|
68
70
|
"bun-plugin-tailwind": "^0.1.2",
|
|
69
71
|
"citty": "^0.2.1",
|
|
70
72
|
"class-variance-authority": "^0.7.1",
|
|
@@ -92,7 +94,7 @@
|
|
|
92
94
|
"react-resizable-panels": "^4.12.2",
|
|
93
95
|
"rehype-highlight": "^7.0.2",
|
|
94
96
|
"remark-gfm": "^4.0.1",
|
|
95
|
-
"shadcn": "
|
|
97
|
+
"shadcn": "4.13.0",
|
|
96
98
|
"sharp": "^0.35.1",
|
|
97
99
|
"shell-quote": "^1.10.0",
|
|
98
100
|
"sugar-high": "^1.2.1",
|
|
@@ -410,6 +410,26 @@ function appletRuntimePlugin(
|
|
|
410
410
|
// provides the same texture utilities available to host components.
|
|
411
411
|
const HOST_THEME_PATH = join(import.meta.dir, '..', '..', 'client', 'theme.css')
|
|
412
412
|
|
|
413
|
+
// The shadcn styling vocabulary, text-inlined from moi's OWN node_modules the
|
|
414
|
+
// same way theme.css is. Tailwind v4 only emits utilities it can resolve:
|
|
415
|
+
// installed ui components lean on `tw-animate-css` (animate-in/out, fade,
|
|
416
|
+
// zoom, slide) and `shadcn/tailwind.css` (data-open/data-closed variants,
|
|
417
|
+
// accordion keyframes, scroll-fade, cn-* helpers) — both imported by the host
|
|
418
|
+
// stylesheet but invisible to an applet's synthetic entry, so those classes
|
|
419
|
+
// were silently dropped and components rendered half-styled. Inlining keeps
|
|
420
|
+
// the workspace dependency-free; emission stays usage-driven, so applets that
|
|
421
|
+
// use none of the vocabulary pay nothing.
|
|
422
|
+
// (`tw-animate-css` exposes its css only under the `style` export condition,
|
|
423
|
+
// which Bun.resolveSync doesn't match — locate it via its package.json.)
|
|
424
|
+
const SHADCN_VOCABULARY_PATHS = [
|
|
425
|
+
join(
|
|
426
|
+
dirname(Bun.resolveSync('tw-animate-css/package.json', import.meta.dir)),
|
|
427
|
+
'dist',
|
|
428
|
+
'tw-animate.css'
|
|
429
|
+
),
|
|
430
|
+
Bun.resolveSync('shadcn/tailwind.css', import.meta.dir)
|
|
431
|
+
]
|
|
432
|
+
|
|
413
433
|
// Three things matter for applet styling:
|
|
414
434
|
// 1. The umbrella `@import 'tailwindcss'` brings in @layer theme + base +
|
|
415
435
|
// utilities — which is what spacing/color utilities like `left-2.5`,
|
|
@@ -444,9 +464,19 @@ async function writeSyntheticTailwindCss(
|
|
|
444
464
|
// (`@source .moi/views`) build concurrently in one `moi bundle`; a shared
|
|
445
465
|
// file would race and point Tailwind at the wrong source dir.
|
|
446
466
|
const cssPath = join(buildDir, `${kind}-tailwind.css`)
|
|
467
|
+
const vocabulary = await Promise.all(SHADCN_VOCABULARY_PATHS.map(path => Bun.file(path).text()))
|
|
447
468
|
const contents = [
|
|
448
469
|
`@import 'tailwindcss';`,
|
|
449
470
|
await Bun.file(HOST_THEME_PATH).text(),
|
|
471
|
+
...vocabulary,
|
|
472
|
+
// Mirror the host's shadcn base-layer default (client/index.css): token
|
|
473
|
+
// border and outline colors on every element. Tailwind v4's preflight sets
|
|
474
|
+
// `border-color: currentColor`, so without this an applet's bare `border`
|
|
475
|
+
// (no explicit color — how installed ui components and shadcn idioms write
|
|
476
|
+
// it) renders black instead of the `border` token. The host applies it
|
|
477
|
+
// page-wide but the applet's scoped sheet must bring its own copy; it gets
|
|
478
|
+
// scoped to the applet subtree like every other rule (applet-css.ts).
|
|
479
|
+
`@layer base { * { @apply border-border outline-ring/50; } }`,
|
|
450
480
|
// Mirror the host's class-based dark mode (client/index.css) so an applet's
|
|
451
481
|
// `dark:` variants flip with the app theme. Without this Tailwind falls
|
|
452
482
|
// back to `@media (prefers-color-scheme: dark)`, which diverges from the
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
// CLI face of `moi ui-components` (see server/ui-components.ts for the
|
|
2
|
+
// engine and docs/moi-shadcn.md for the spec). Three verbs:
|
|
3
|
+
//
|
|
4
|
+
// moi ui-components → the curated catalog + installed state
|
|
5
|
+
// moi ui-components add <name…> → fetch, transform, write to .moi/ui/
|
|
6
|
+
// moi ui-components docs <name…> → official docs as markdown, on stdout
|
|
7
|
+
//
|
|
8
|
+
// The command is deliberately not smart: add never installs dependencies,
|
|
9
|
+
// never rebuilds, never edits existing files — it prints next steps and the
|
|
10
|
+
// agent owns them.
|
|
11
|
+
import { defineCommand } from 'citty'
|
|
12
|
+
import { existsSync } from 'node:fs'
|
|
13
|
+
import { mkdir } from 'node:fs/promises'
|
|
14
|
+
import { join, relative } from 'path'
|
|
15
|
+
|
|
16
|
+
import pc from './cli-pc'
|
|
17
|
+
import { resolveCwdWorkspace } from './cli-env'
|
|
18
|
+
import { MOI_PACKAGE_JSON } from './moi-scaffold'
|
|
19
|
+
import {
|
|
20
|
+
UI_COMPONENTS,
|
|
21
|
+
UI_COMPONENT_NAMES,
|
|
22
|
+
UI_DOCS_BASE,
|
|
23
|
+
fetchUiComponents,
|
|
24
|
+
planUiWrites,
|
|
25
|
+
resolveUiComponentRequest,
|
|
26
|
+
suggestUiComponents,
|
|
27
|
+
transformUiComponentSource
|
|
28
|
+
} from './ui-components'
|
|
29
|
+
|
|
30
|
+
function uiDirFor(workspacePath: string): string {
|
|
31
|
+
return join(workspacePath, '.moi', 'ui')
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function exitUnknownNames(unknown: string[]): never {
|
|
35
|
+
for (const name of unknown) {
|
|
36
|
+
const hints = suggestUiComponents(name)
|
|
37
|
+
console.error(
|
|
38
|
+
pc.red('✗') +
|
|
39
|
+
` "${name}" is not in the moi component set.` +
|
|
40
|
+
(hints.length ? pc.dim(` Did you mean: ${hints.join(', ')}?`) : '')
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
console.error(pc.dim('\n moi ui-components — the full catalog\n'))
|
|
44
|
+
process.exit(1)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const add = defineCommand({
|
|
48
|
+
meta: {
|
|
49
|
+
name: 'add',
|
|
50
|
+
description: 'Fetch components from the shadcn registry into .moi/ui/'
|
|
51
|
+
},
|
|
52
|
+
args: {
|
|
53
|
+
name: {
|
|
54
|
+
type: 'positional',
|
|
55
|
+
required: true,
|
|
56
|
+
description: 'Component names (see `moi ui-components`)'
|
|
57
|
+
},
|
|
58
|
+
force: {
|
|
59
|
+
type: 'boolean',
|
|
60
|
+
default: false,
|
|
61
|
+
description: 'Overwrite existing files of the requested components'
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
async run({ args }) {
|
|
65
|
+
const request = resolveUiComponentRequest(args._)
|
|
66
|
+
if (request.unknown.length > 0) exitUnknownNames(request.unknown)
|
|
67
|
+
|
|
68
|
+
const entry = await resolveCwdWorkspace()
|
|
69
|
+
const uiDir = uiDirFor(entry.path)
|
|
70
|
+
|
|
71
|
+
let fetched
|
|
72
|
+
try {
|
|
73
|
+
fetched = await fetchUiComponents(request.registryItems)
|
|
74
|
+
} catch (err) {
|
|
75
|
+
console.error(
|
|
76
|
+
'\n' +
|
|
77
|
+
pc.red('✗') +
|
|
78
|
+
' Could not reach the shadcn registry (ui.shadcn.com). ' +
|
|
79
|
+
'The command needs network access; offline use is not supported.\n' +
|
|
80
|
+
pc.dim(` ${(err as Error).message}\n`)
|
|
81
|
+
)
|
|
82
|
+
process.exit(1)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const plans = planUiWrites({
|
|
86
|
+
files: fetched.files,
|
|
87
|
+
requestedItems: request.registryItems,
|
|
88
|
+
uiDir,
|
|
89
|
+
exists: existsSync
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
// Hand-customized components are never silently overwritten: any requested
|
|
93
|
+
// file that already exists fails the whole add unless --force. Existing
|
|
94
|
+
// support files (utils, applet-portal, registry deps that rode along) are
|
|
95
|
+
// kept as-is either way.
|
|
96
|
+
const conflicts = plans.filter(plan => plan.exists && !plan.support)
|
|
97
|
+
if (conflicts.length > 0 && !args.force) {
|
|
98
|
+
console.error(
|
|
99
|
+
'\n' +
|
|
100
|
+
pc.red('✗') +
|
|
101
|
+
' Already installed: ' +
|
|
102
|
+
conflicts.map(plan => pc.bold(plan.name)).join(', ') +
|
|
103
|
+
'\n' +
|
|
104
|
+
pc.dim(' Files in .moi/ui/ may carry your customizations.\n') +
|
|
105
|
+
pc.dim(' Re-run with --force to overwrite them.\n')
|
|
106
|
+
)
|
|
107
|
+
process.exit(1)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
await mkdir(uiDir, { recursive: true })
|
|
111
|
+
const written: string[] = []
|
|
112
|
+
const kept: string[] = []
|
|
113
|
+
for (const plan of plans) {
|
|
114
|
+
if (plan.exists && plan.support) {
|
|
115
|
+
kept.push(plan.name)
|
|
116
|
+
continue
|
|
117
|
+
}
|
|
118
|
+
const content = plan.name.endsWith('.tsx')
|
|
119
|
+
? await transformUiComponentSource(plan.name, plan.content)
|
|
120
|
+
: plan.content
|
|
121
|
+
await Bun.write(plan.path, content)
|
|
122
|
+
written.push(plan.name)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Deps the `moi init` scaffold already pre-seeds never need a mention;
|
|
126
|
+
// registry specifiers may be versioned (`recharts@3.8.0`), so compare by
|
|
127
|
+
// package name.
|
|
128
|
+
const baseline = new Set(Object.keys(MOI_PACKAGE_JSON.dependencies))
|
|
129
|
+
const deps = [...new Set([...fetched.dependencies, ...request.extraDeps])]
|
|
130
|
+
.filter(spec => !baseline.has(spec.replace(/@[^@/]+$/, '')))
|
|
131
|
+
.sort()
|
|
132
|
+
|
|
133
|
+
console.log('\n' + pc.green('✓') + ' Added to ' + pc.bold('.moi/ui/') + ':')
|
|
134
|
+
console.log(pc.dim(' ' + written.join(', ')))
|
|
135
|
+
if (kept.length > 0) {
|
|
136
|
+
console.log(pc.dim(` kept existing: ${kept.join(', ')}`))
|
|
137
|
+
}
|
|
138
|
+
console.log('\nNext steps (yours):')
|
|
139
|
+
if (deps.length > 0) {
|
|
140
|
+
// The command runs from anywhere inside the workspace (resolveCwdWorkspace),
|
|
141
|
+
// so point the install at the real `.moi/` relative to the caller's cwd —
|
|
142
|
+
// a literal `cd .moi` is wrong from `.moi/` itself or a widgets/ subdir.
|
|
143
|
+
const moiDir = join(entry.path, '.moi')
|
|
144
|
+
const rel = relative(process.cwd(), moiDir)
|
|
145
|
+
const cdPrefix = rel === '' ? '' : `cd ${/\s/.test(rel) ? JSON.stringify(rel) : rel} && `
|
|
146
|
+
console.log(
|
|
147
|
+
' 1. Install dependencies: ' + pc.bold(`${cdPrefix}bun install ${deps.join(' ')}`)
|
|
148
|
+
)
|
|
149
|
+
console.log(' 2. Import relatively — ' + pc.bold(`import { … } from '../ui/<name>'`))
|
|
150
|
+
console.log(' 3. Rebuild: ' + pc.bold('moi bundle'))
|
|
151
|
+
} else {
|
|
152
|
+
console.log(' 1. Import relatively — ' + pc.bold(`import { … } from '../ui/<name>'`))
|
|
153
|
+
console.log(' 2. Rebuild: ' + pc.bold('moi bundle'))
|
|
154
|
+
}
|
|
155
|
+
console.log(pc.dim(`\n Component docs: moi ui-components docs ${request.entries[0]}\n`))
|
|
156
|
+
}
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
const docs = defineCommand({
|
|
160
|
+
meta: {
|
|
161
|
+
name: 'docs',
|
|
162
|
+
description: 'Print official component docs as markdown'
|
|
163
|
+
},
|
|
164
|
+
args: {
|
|
165
|
+
name: {
|
|
166
|
+
type: 'positional',
|
|
167
|
+
required: true,
|
|
168
|
+
description: 'Component names (see `moi ui-components`)'
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
async run({ args }) {
|
|
172
|
+
const request = resolveUiComponentRequest(args._)
|
|
173
|
+
if (request.unknown.length > 0) exitUnknownNames(request.unknown)
|
|
174
|
+
|
|
175
|
+
for (const name of request.entries) {
|
|
176
|
+
const slug = UI_COMPONENTS[name].docsSlug ?? name
|
|
177
|
+
const url = `${UI_DOCS_BASE}/${slug}.md`
|
|
178
|
+
try {
|
|
179
|
+
const res = await fetch(url, { signal: AbortSignal.timeout(20_000) })
|
|
180
|
+
if (!res.ok) throw new Error(`HTTP ${res.status}`)
|
|
181
|
+
if (request.entries.length > 1) console.log(`\n---\n# ${name}\n`)
|
|
182
|
+
console.log(await res.text())
|
|
183
|
+
} catch (err) {
|
|
184
|
+
console.error(
|
|
185
|
+
pc.red('✗') + ` Could not fetch docs for "${name}" (${url}): ${(err as Error).message}`
|
|
186
|
+
)
|
|
187
|
+
process.exitCode = 1
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
function renderCatalog(uiDir: string, query?: string): void {
|
|
194
|
+
const needle = query?.toLowerCase()
|
|
195
|
+
const pad = Math.max(...UI_COMPONENT_NAMES.map(name => name.length)) + 2
|
|
196
|
+
const rows: string[] = []
|
|
197
|
+
for (const name of UI_COMPONENT_NAMES) {
|
|
198
|
+
const entry = UI_COMPONENTS[name]
|
|
199
|
+
if (needle && !name.includes(needle) && !entry.description.toLowerCase().includes(needle)) {
|
|
200
|
+
continue
|
|
201
|
+
}
|
|
202
|
+
const installed = entry.registryItems.every(item => existsSync(join(uiDir, `${item}.tsx`)))
|
|
203
|
+
rows.push(
|
|
204
|
+
' ' +
|
|
205
|
+
(installed ? pc.green('✓ ') : ' ') +
|
|
206
|
+
pc.cyan(name.padEnd(pad)) +
|
|
207
|
+
pc.dim(entry.description)
|
|
208
|
+
)
|
|
209
|
+
}
|
|
210
|
+
if (rows.length === 0) {
|
|
211
|
+
console.log('\n' + pc.dim(` Nothing matches "${query}".`) + '\n')
|
|
212
|
+
return
|
|
213
|
+
}
|
|
214
|
+
console.log()
|
|
215
|
+
console.log(rows.join('\n'))
|
|
216
|
+
console.log(
|
|
217
|
+
'\n' +
|
|
218
|
+
pc.dim(' ✓ installed in .moi/ui/ · add: ') +
|
|
219
|
+
pc.bold('moi ui-components add <name>') +
|
|
220
|
+
pc.dim(' · docs: ') +
|
|
221
|
+
pc.bold('moi ui-components docs <name>') +
|
|
222
|
+
'\n'
|
|
223
|
+
)
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const list = defineCommand({
|
|
227
|
+
meta: {
|
|
228
|
+
name: 'list',
|
|
229
|
+
description: 'The component catalog with installed state'
|
|
230
|
+
},
|
|
231
|
+
args: {
|
|
232
|
+
q: {
|
|
233
|
+
type: 'string',
|
|
234
|
+
description: 'Filter by name or description'
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
async run({ args }) {
|
|
238
|
+
const entry = await resolveCwdWorkspace()
|
|
239
|
+
renderCatalog(uiDirFor(entry.path), args.q)
|
|
240
|
+
}
|
|
241
|
+
})
|
|
242
|
+
|
|
243
|
+
// Exported so cli.ts can keep a static command shell (name + description, all
|
|
244
|
+
// the root help needs) and pull this module in only when a subcommand actually
|
|
245
|
+
// runs — see the lazy `uiComponents` there.
|
|
246
|
+
export const uiComponentsSubCommands = { add, docs, list }
|
|
247
|
+
|
|
248
|
+
// The bare `moi ui-components` behavior, factored out of the command object so
|
|
249
|
+
// cli.ts can invoke it from a static shell without importing this module until
|
|
250
|
+
// the command actually runs.
|
|
251
|
+
export async function runUiComponentsCatalog(rawArgs: string[]): Promise<void> {
|
|
252
|
+
// citty invokes the parent run even after dispatching a subcommand — only
|
|
253
|
+
// render the catalog when no subcommand ran (same pattern as `moi env`).
|
|
254
|
+
const first = rawArgs.find(a => !a.startsWith('-'))
|
|
255
|
+
if (first && Object.hasOwn(uiComponentsSubCommands, first)) return
|
|
256
|
+
const entry = await resolveCwdWorkspace()
|
|
257
|
+
renderCatalog(uiDirFor(entry.path))
|
|
258
|
+
}
|
package/server/cli.ts
CHANGED
|
@@ -12,13 +12,14 @@ import { isAgentCaller } from './agent-caller'
|
|
|
12
12
|
import { getAppConfig } from './app-config'
|
|
13
13
|
|
|
14
14
|
import {
|
|
15
|
+
AGENT_THEMES,
|
|
15
16
|
COLOR_THEMES,
|
|
16
17
|
DEFAULT_WORKSPACE_THEME,
|
|
17
18
|
FONT_THEMES,
|
|
18
19
|
RADIUS_THEMES,
|
|
19
20
|
deriveThemeColors
|
|
20
21
|
} from '@/lib/themes'
|
|
21
|
-
import type { ColorTheme, FontTheme, RadiusTheme } from '@/lib/themes'
|
|
22
|
+
import type { AgentTheme, ColorTheme, FontTheme, RadiusTheme } from '@/lib/themes'
|
|
22
23
|
import { isParamsRecord } from '@/lib/workspace-tabs'
|
|
23
24
|
import type {
|
|
24
25
|
AppletLogEntry,
|
|
@@ -819,7 +820,8 @@ const theme = defineCommand({
|
|
|
819
820
|
},
|
|
820
821
|
font: { type: 'string', description: 'Font theme key to apply' },
|
|
821
822
|
color: { type: 'string', description: 'Color preset key to apply' },
|
|
822
|
-
radius: { type: 'string', description: 'Radius preset key to apply' }
|
|
823
|
+
radius: { type: 'string', description: 'Radius preset key to apply' },
|
|
824
|
+
agent: { type: 'string', description: 'Agent preset key to apply' }
|
|
823
825
|
},
|
|
824
826
|
async run({ args }) {
|
|
825
827
|
const path = resolve(args.dir)
|
|
@@ -833,7 +835,8 @@ const theme = defineCommand({
|
|
|
833
835
|
path,
|
|
834
836
|
font: args.font ?? null,
|
|
835
837
|
color: args.color ?? null,
|
|
836
|
-
radius: args.radius ?? null
|
|
838
|
+
radius: args.radius ?? null,
|
|
839
|
+
agent: args.agent ?? null
|
|
837
840
|
})
|
|
838
841
|
)
|
|
839
842
|
|
|
@@ -866,6 +869,10 @@ const theme = defineCommand({
|
|
|
866
869
|
const preset = RADIUS_THEMES[res.radius as RadiusTheme]
|
|
867
870
|
console.log(pc.green('✓') + ' Radius set to ' + pc.bold(preset.label))
|
|
868
871
|
}
|
|
872
|
+
if (res.agent) {
|
|
873
|
+
const preset = AGENT_THEMES[res.agent as AgentTheme]
|
|
874
|
+
console.log(pc.green('✓') + ' Agent set to ' + pc.bold(preset.label))
|
|
875
|
+
}
|
|
869
876
|
console.log()
|
|
870
877
|
if (notice) console.log(pc.yellow(notice) + '\n')
|
|
871
878
|
ws.close()
|
|
@@ -875,8 +882,11 @@ const theme = defineCommand({
|
|
|
875
882
|
const currentFont: FontTheme = res.currentFont ?? DEFAULT_WORKSPACE_THEME.font
|
|
876
883
|
const currentColor: ColorTheme = res.currentColor ?? DEFAULT_WORKSPACE_THEME.color
|
|
877
884
|
const currentRadius: RadiusTheme = res.currentRadius ?? DEFAULT_WORKSPACE_THEME.radius
|
|
885
|
+
const currentAgent: AgentTheme = res.currentAgent ?? DEFAULT_WORKSPACE_THEME.agent
|
|
878
886
|
console.log('\n' + pc.bold('moi theme') + ' — workspace appearance')
|
|
879
|
-
console.log(
|
|
887
|
+
console.log(
|
|
888
|
+
pc.dim(' Usage: moi theme --font=<key> --color=<key> --radius=<key> --agent=<key>') + '\n'
|
|
889
|
+
)
|
|
880
890
|
|
|
881
891
|
const fontRows = (Object.keys(FONT_THEMES) as FontTheme[]).map(key => {
|
|
882
892
|
const f = FONT_THEMES[key]
|
|
@@ -933,6 +943,19 @@ const theme = defineCommand({
|
|
|
933
943
|
) + '\n'
|
|
934
944
|
)
|
|
935
945
|
|
|
946
|
+
const agentRows = (Object.keys(AGENT_THEMES) as AgentTheme[]).map(key => {
|
|
947
|
+
const agent = AGENT_THEMES[key]
|
|
948
|
+
const selected = key === currentAgent
|
|
949
|
+
return [selected ? pc.green('→') : ' ', selected ? pc.bold(key) : key, agent.label]
|
|
950
|
+
})
|
|
951
|
+
console.log(pc.dim(' Agent'))
|
|
952
|
+
console.log(
|
|
953
|
+
columns(
|
|
954
|
+
['', 'key', 'label'].map(h => pc.dim(h)),
|
|
955
|
+
agentRows
|
|
956
|
+
) + '\n'
|
|
957
|
+
)
|
|
958
|
+
|
|
936
959
|
if (notice) console.log(pc.yellow(notice) + '\n')
|
|
937
960
|
ws.close()
|
|
938
961
|
process.exit(0)
|
|
@@ -2923,6 +2946,25 @@ const version = defineCommand({
|
|
|
2923
2946
|
}
|
|
2924
2947
|
})
|
|
2925
2948
|
|
|
2949
|
+
// A static shell over ./cli-ui-components, which reaches `shadcn` and
|
|
2950
|
+
// `ts-morph` — ~31 MB of JS that costs ~300 ms to parse and evaluate. The meta
|
|
2951
|
+
// is inlined here (duplicating the real command's) because it is all the root
|
|
2952
|
+
// help needs: both citty's usage renderer and printMainHelp read only
|
|
2953
|
+
// `meta.description`, so a lazily-resolved subcommand would be imported by
|
|
2954
|
+
// every `moi --help`. Keeping the shell static defers the module to the point
|
|
2955
|
+
// where a subcommand actually runs.
|
|
2956
|
+
const uiComponents = defineCommand({
|
|
2957
|
+
meta: {
|
|
2958
|
+
name: 'ui-components',
|
|
2959
|
+
description: 'Standard UI components for applets (curated shadcn set)'
|
|
2960
|
+
},
|
|
2961
|
+
subCommands: () => import('./cli-ui-components').then(m => m.uiComponentsSubCommands),
|
|
2962
|
+
async run({ rawArgs }) {
|
|
2963
|
+
const { runUiComponentsCatalog } = await import('./cli-ui-components')
|
|
2964
|
+
await runUiComponentsCatalog(rawArgs)
|
|
2965
|
+
}
|
|
2966
|
+
})
|
|
2967
|
+
|
|
2926
2968
|
// The root help splits the surface by audience: workspace commands are the
|
|
2927
2969
|
// agent's day-to-day toolkit (skills tell it to run them); system commands
|
|
2928
2970
|
// manage moi itself and are for the human at the keyboard.
|
|
@@ -2938,7 +2980,8 @@ const workspaceCommands = {
|
|
|
2938
2980
|
scratch,
|
|
2939
2981
|
skill,
|
|
2940
2982
|
tab,
|
|
2941
|
-
tabs
|
|
2983
|
+
tabs,
|
|
2984
|
+
'ui-components': uiComponents
|
|
2942
2985
|
}
|
|
2943
2986
|
|
|
2944
2987
|
const systemCommands = {
|
package/server/control.ts
CHANGED
|
@@ -355,13 +355,14 @@ export const control = Bun.serve({
|
|
|
355
355
|
const layout = await loadLayout(workspacePath)
|
|
356
356
|
|
|
357
357
|
// Listing mode — no theme setting requested
|
|
358
|
-
if (!data.font && !data.color && !data.radius) {
|
|
358
|
+
if (!data.font && !data.color && !data.radius && !data.agent) {
|
|
359
359
|
const theme = resolveWorkspaceTheme(layout.theme)
|
|
360
360
|
ws.send(
|
|
361
361
|
JSON.stringify({
|
|
362
362
|
currentFont: theme.font,
|
|
363
363
|
currentColor: theme.color,
|
|
364
|
-
currentRadius: theme.radius
|
|
364
|
+
currentRadius: theme.radius,
|
|
365
|
+
currentAgent: theme.agent
|
|
365
366
|
})
|
|
366
367
|
)
|
|
367
368
|
return
|
|
@@ -370,7 +371,8 @@ export const control = Bun.serve({
|
|
|
370
371
|
const result = applyThemeUpdate(layout.theme, {
|
|
371
372
|
font: data.font,
|
|
372
373
|
color: data.color,
|
|
373
|
-
radius: data.radius
|
|
374
|
+
radius: data.radius,
|
|
375
|
+
agent: data.agent
|
|
374
376
|
})
|
|
375
377
|
if (!result.ok) {
|
|
376
378
|
ws.send(JSON.stringify({ error: result.error }))
|
package/server/moi-scaffold.ts
CHANGED
|
@@ -15,7 +15,15 @@ export const MOI_PACKAGE_JSON = {
|
|
|
15
15
|
'@tabler/icons-react': '^3.40.0',
|
|
16
16
|
tailwindcss: '^4.3.3',
|
|
17
17
|
react: '^19.0.0',
|
|
18
|
-
'react-dom': '^19.0.0'
|
|
18
|
+
'react-dom': '^19.0.0',
|
|
19
|
+
// The `moi ui-components` baseline: every installed component leans on
|
|
20
|
+
// Base UI primitives and the cn() stack, so one install at workspace
|
|
21
|
+
// creation covers the common path. Component-specific deps (recharts,
|
|
22
|
+
// embla, …) stay agent-installed on demand — `add` prints them.
|
|
23
|
+
'@base-ui/react': '^1.2.0',
|
|
24
|
+
'class-variance-authority': '^0.7.1',
|
|
25
|
+
clsx: '^2.1.1',
|
|
26
|
+
'tailwind-merge': '^3.3.1'
|
|
19
27
|
},
|
|
20
28
|
devDependencies: {
|
|
21
29
|
'@types/react': '^19.0.0',
|
|
@@ -17,6 +17,11 @@ export const BUNDLED_SKILLS_DIR = join(TEMPLATE_DIR, '.claude', 'skills')
|
|
|
17
17
|
// Copy each shipped skill folder into `targetSkillsDir`. Overwrites existing
|
|
18
18
|
// files (e.g. on a re-install after a moi upgrade) but leaves unrelated
|
|
19
19
|
// directories alone. Creates the target if missing.
|
|
20
|
+
//
|
|
21
|
+
// The ui-components section used to be stripped here unless a workspace opted
|
|
22
|
+
// in with `moi init --experimental-shadcn`. It ships to everyone now; the skill
|
|
23
|
+
// version bump is what pulls it into workspaces installed before the flag went
|
|
24
|
+
// away (the copy below restores both the section and its cheat sheet).
|
|
20
25
|
export async function installBundledSkills(targetSkillsDir: string): Promise<void> {
|
|
21
26
|
await mkdir(targetSkillsDir, { recursive: true })
|
|
22
27
|
await cp(BUNDLED_SKILLS_DIR, targetSkillsDir, {
|
package/server/theme.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
AGENT_THEMES,
|
|
3
|
+
COLOR_THEMES,
|
|
4
|
+
FONT_THEMES,
|
|
5
|
+
RADIUS_THEMES,
|
|
6
|
+
resolveWorkspaceTheme
|
|
7
|
+
} from '@/lib/themes'
|
|
8
|
+
import type { AgentTheme, ColorTheme, FontTheme, RadiusTheme, WorkspaceTheme } from '@/lib/types'
|
|
3
9
|
|
|
4
|
-
export type ThemeUpdate = { font?: string; color?: string; radius?: string }
|
|
10
|
+
export type ThemeUpdate = { font?: string; color?: string; radius?: string; agent?: string }
|
|
5
11
|
export type ThemeUpdateResult =
|
|
6
12
|
| {
|
|
7
13
|
ok: true
|
|
@@ -23,15 +29,20 @@ export function applyThemeUpdate(
|
|
|
23
29
|
if (update.radius && !(update.radius in RADIUS_THEMES)) {
|
|
24
30
|
return { ok: false, error: `Unknown radius theme: ${update.radius}` }
|
|
25
31
|
}
|
|
32
|
+
if (update.agent && !(update.agent in AGENT_THEMES)) {
|
|
33
|
+
return { ok: false, error: `Unknown agent theme: ${update.agent}` }
|
|
34
|
+
}
|
|
26
35
|
|
|
27
36
|
const font = update.font as FontTheme | undefined
|
|
28
37
|
const color = update.color as ColorTheme | undefined
|
|
29
38
|
const radius = update.radius as RadiusTheme | undefined
|
|
39
|
+
const agent = update.agent as AgentTheme | undefined
|
|
30
40
|
const theme = resolveWorkspaceTheme({
|
|
31
41
|
...current,
|
|
32
42
|
...(font ? { font } : {}),
|
|
33
43
|
...(color ? { color } : {}),
|
|
34
|
-
...(radius ? { radius } : {})
|
|
44
|
+
...(radius ? { radius } : {}),
|
|
45
|
+
...(agent ? { agent } : {})
|
|
35
46
|
})
|
|
36
47
|
|
|
37
48
|
return {
|
|
@@ -40,7 +51,8 @@ export function applyThemeUpdate(
|
|
|
40
51
|
applied: {
|
|
41
52
|
...(font ? { font } : {}),
|
|
42
53
|
...(color ? { color } : {}),
|
|
43
|
-
...(radius ? { radius } : {})
|
|
54
|
+
...(radius ? { radius } : {}),
|
|
55
|
+
...(agent ? { agent } : {})
|
|
44
56
|
}
|
|
45
57
|
}
|
|
46
58
|
}
|