moi-computer 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/client/components/shared/BottomPanel.tsx +2 -1
- package/client/components/shared/PanelHeader.tsx +1 -1
- package/client/features/applets/AppletMount.tsx +9 -22
- package/client/features/applets/applet-cache.ts +7 -0
- package/client/features/applets/applet-styles.ts +21 -1
- package/client/features/applets/useApplet.ts +1 -1
- package/client/features/chat/ChatComposer.tsx +18 -4
- package/client/features/chat/ChatSelector.tsx +1 -1
- package/client/features/chat/TurnView.tsx +1 -1
- package/client/features/home/api.ts +0 -10
- package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +21 -64
- package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +1 -1
- package/client/features/scratchpad/Scratchpad.tsx +1 -3
- package/client/features/views/ViewManager.tsx +258 -0
- package/client/features/views/view-residency.ts +77 -0
- package/client/features/widgets/WidgetFrame.tsx +6 -2
- package/client/features/workspace/CustomizePanel.tsx +40 -24
- package/client/features/workspace/WorkspaceLayoutContext.tsx +8 -0
- package/client/features/workspace/WorkspaceScreen.tsx +51 -103
- package/client/features/workspace/WorkspaceTabs.tsx +1 -1
- package/client/index.css +4 -1
- package/client/runtime/workspace-theme.ts +29 -10
- package/client/theme.css +96 -6
- package/dist/chunk-0k7brsms.js +9 -0
- package/dist/{chunk-m11ckkxd.js → chunk-dtwxpxbg.js} +1 -1
- package/dist/{chunk-55sh4dty.js → chunk-ga7t9qsk.js} +1 -1
- package/dist/{chunk-w3tnv51j.js → chunk-h9h8f176.js} +1 -1
- package/dist/{chunk-rxvx4ta9.js → chunk-r5ce5cdg.js} +2 -2
- package/dist/chunk-tey2nq7c.js +31 -0
- package/dist/{chunk-afgbg75t.js → chunk-z73xpsa0.js} +1 -1
- package/dist/chunk-zzgredta.css +1 -0
- package/dist/index.html +1 -1
- package/lib/themes.ts +123 -51
- package/lib/types.ts +2 -5
- package/package.json +5 -4
- package/server/api.ts +2 -73
- package/server/bundler/build-applet.ts +7 -4
- package/server/cli.ts +46 -15
- package/server/control.ts +13 -6
- package/server/moi-scaffold.ts +1 -1
- package/server/registry.ts +0 -20
- package/server/theme.ts +24 -27
- package/workspace/.claude/skills/moi-workspace/DESIGN.md +94 -57
- package/workspace/.claude/skills/moi-workspace/SKILL.md +10 -12
- package/dist/chunk-175bm057.js +0 -27
- package/dist/chunk-agtetn7n.css +0 -1
- package/dist/chunk-exj6hr30.js +0 -9
package/lib/themes.ts
CHANGED
|
@@ -1,85 +1,131 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import a11yPlugin from 'colord/plugins/a11y'
|
|
1
|
+
import { wcagLuminance } from 'culori'
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
export type FontTheme =
|
|
4
|
+
| 'sans'
|
|
5
|
+
| 'serif'
|
|
6
|
+
| 'mono'
|
|
7
|
+
| 'geometric'
|
|
8
|
+
| 'rounded'
|
|
9
|
+
| 'blobby'
|
|
10
|
+
| 'awkward'
|
|
11
|
+
| 'comic'
|
|
8
12
|
|
|
9
13
|
export type FontThemeConfig = {
|
|
10
14
|
label: string
|
|
11
|
-
feel: string
|
|
12
15
|
sans: string
|
|
13
16
|
mono: string
|
|
14
17
|
googleFontsQuery?: string // passed as `family=` param to Google Fonts API
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
export const FONT_THEMES: Record<FontTheme, FontThemeConfig> = {
|
|
18
|
-
|
|
19
|
-
label: '
|
|
20
|
-
feel: 'System font',
|
|
21
|
+
sans: {
|
|
22
|
+
label: 'Sans',
|
|
21
23
|
sans: 'system-ui',
|
|
22
24
|
mono: 'Geist Mono',
|
|
23
25
|
googleFontsQuery: 'Geist+Mono:wght@400;500'
|
|
24
26
|
},
|
|
25
27
|
serif: {
|
|
26
28
|
label: 'Serif',
|
|
27
|
-
feel: 'Literata',
|
|
28
29
|
sans: 'Literata',
|
|
29
30
|
mono: 'Geist Mono',
|
|
30
31
|
googleFontsQuery: 'Literata:wght@400;600;700&family=Geist+Mono:wght@400;500'
|
|
31
32
|
},
|
|
32
33
|
mono: {
|
|
33
34
|
label: 'Mono',
|
|
34
|
-
feel: 'Geist Mono',
|
|
35
35
|
sans: 'Geist Mono',
|
|
36
36
|
mono: 'Geist Mono',
|
|
37
37
|
googleFontsQuery: 'Geist+Mono:wght@400;500;600'
|
|
38
38
|
},
|
|
39
|
-
blobby: {
|
|
40
|
-
label: 'Blobby',
|
|
41
|
-
feel: 'Sour Gummy',
|
|
42
|
-
sans: 'Sour Gummy',
|
|
43
|
-
mono: 'Azeret Mono',
|
|
44
|
-
googleFontsQuery: 'Sour+Gummy:wght@400;500;600&family=Azeret+Mono:wght@400;500'
|
|
45
|
-
},
|
|
46
39
|
geometric: {
|
|
47
40
|
label: 'Geometric',
|
|
48
|
-
feel: 'Manrope',
|
|
49
41
|
sans: 'Manrope',
|
|
50
42
|
mono: 'Geist Mono',
|
|
51
43
|
googleFontsQuery: 'Manrope:wght@400;500;600&family=Geist+Mono:wght@400;500'
|
|
52
44
|
},
|
|
45
|
+
rounded: {
|
|
46
|
+
label: 'Rounded',
|
|
47
|
+
sans: 'SN Pro',
|
|
48
|
+
mono: 'Geist Mono',
|
|
49
|
+
googleFontsQuery: 'SN+Pro:wght@400;500;600&family=Geist+Mono:wght@400;500'
|
|
50
|
+
},
|
|
51
|
+
blobby: {
|
|
52
|
+
label: 'Blobby',
|
|
53
|
+
sans: 'Sour Gummy',
|
|
54
|
+
mono: 'Azeret Mono',
|
|
55
|
+
googleFontsQuery: 'Sour+Gummy:wght@400;500;600&family=Azeret+Mono:wght@400;500'
|
|
56
|
+
},
|
|
53
57
|
awkward: {
|
|
54
58
|
label: 'Awkward',
|
|
55
|
-
feel: 'Averia Sans Libre',
|
|
56
59
|
sans: 'Averia Sans Libre',
|
|
57
60
|
mono: 'Azeret Mono',
|
|
58
61
|
googleFontsQuery: 'Averia+Sans+Libre:wght@400;500;600&family=Azeret+Mono:wght@400;500'
|
|
62
|
+
},
|
|
63
|
+
comic: {
|
|
64
|
+
label: 'Comic',
|
|
65
|
+
sans: 'Comic Sans MS, Comic Sans, cursive',
|
|
66
|
+
mono: 'Geist Mono',
|
|
67
|
+
googleFontsQuery: 'Geist+Mono:wght@400;500'
|
|
59
68
|
}
|
|
60
69
|
}
|
|
61
70
|
|
|
62
|
-
export type
|
|
71
|
+
export type RadiusTheme = 'squishy' | 'soft' | 'subtle' | 'square'
|
|
63
72
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
73
|
+
export type RadiusThemeConfig = {
|
|
74
|
+
label: string
|
|
75
|
+
radius: string
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const RADIUS_THEMES: Record<RadiusTheme, RadiusThemeConfig> = {
|
|
79
|
+
squishy: { label: 'Squishy', radius: '0.875rem' },
|
|
80
|
+
soft: { label: 'Soft', radius: '0.625rem' },
|
|
81
|
+
subtle: { label: 'Subtle', radius: '0.375rem' },
|
|
82
|
+
square: { label: 'Square', radius: '0' }
|
|
83
|
+
}
|
|
68
84
|
|
|
69
|
-
|
|
85
|
+
export type ColorTheme =
|
|
86
|
+
| 'default'
|
|
87
|
+
| 'paper'
|
|
88
|
+
| 'rose'
|
|
89
|
+
| 'tangerine'
|
|
90
|
+
| 'sand'
|
|
91
|
+
| 'mint'
|
|
92
|
+
| 'sky'
|
|
93
|
+
| 'lavender'
|
|
94
|
+
|
|
95
|
+
export type ThemeColorMode = 'workspace' | 'widget'
|
|
96
|
+
|
|
97
|
+
export const DEFAULT_PRIMARY_COLOR = 'oklch(0.205 0 0)'
|
|
98
|
+
|
|
99
|
+
function foregroundForPrimary(primary: string): string {
|
|
100
|
+
return wcagLuminance(primary) > 0.3 ? 'oklch(0 0 0)' : 'oklch(1 0 0)'
|
|
70
101
|
}
|
|
71
102
|
|
|
72
103
|
const THEME_COLOR_DERIVATIONS = {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
104
|
+
workspace: {
|
|
105
|
+
primary: primary => primary,
|
|
106
|
+
primaryForeground: primary => foregroundForPrimary(primary),
|
|
107
|
+
background: () => 'color-mix(var(--primary) 3%, oklch(1 0 0) 97%)',
|
|
108
|
+
foreground: () => 'color-mix(var(--primary) 20%, oklch(0 0 0) 80%)',
|
|
109
|
+
muted: () => 'color-mix(var(--background) 95%, var(--foreground) 5%)',
|
|
110
|
+
mutedForeground: () => 'color-mix(var(--background) 50%, var(--foreground) 50%)',
|
|
111
|
+
accent: () => 'color-mix(var(--primary) 4%, var(--foreground) 4%)',
|
|
112
|
+
accentForeground: () => 'var(--foreground)',
|
|
113
|
+
border: () => 'color-mix(var(--foreground) 7%, transparent)'
|
|
114
|
+
},
|
|
115
|
+
widget: {
|
|
116
|
+
background: primary => primary,
|
|
117
|
+
foreground: primary => foregroundForPrimary(primary),
|
|
118
|
+
primary: () => 'color-mix(var(--background) 3%, oklch(1 0 0) 97%)',
|
|
119
|
+
primaryForeground: () => 'color-mix(var(--background) 20%, oklch(0 0 0) 80%)',
|
|
120
|
+
muted: () => 'color-mix(var(--background) 95%, var(--foreground) 5%)',
|
|
121
|
+
mutedForeground: () => 'color-mix(var(--background) 50%, var(--foreground) 50%)',
|
|
122
|
+
accent: () => 'color-mix(var(--primary) 4%, var(--foreground) 4%)',
|
|
123
|
+
accentForeground: () => 'var(--foreground)',
|
|
124
|
+
border: () => 'color-mix(var(--foreground) 15%, transparent)'
|
|
125
|
+
}
|
|
126
|
+
} satisfies Record<ThemeColorMode, Record<string, (primary: string) => string>>
|
|
127
|
+
|
|
128
|
+
export type ThemeColorToken = keyof (typeof THEME_COLOR_DERIVATIONS)['workspace']
|
|
83
129
|
export type ThemeColors = Record<ThemeColorToken, string>
|
|
84
130
|
|
|
85
131
|
export type ColorThemeConfig = {
|
|
@@ -88,12 +134,18 @@ export type ColorThemeConfig = {
|
|
|
88
134
|
primary?: string
|
|
89
135
|
}
|
|
90
136
|
|
|
91
|
-
export const THEME_COLOR_TOKENS = Object.keys(
|
|
137
|
+
export const THEME_COLOR_TOKENS = Object.keys(
|
|
138
|
+
THEME_COLOR_DERIVATIONS.workspace
|
|
139
|
+
) as ThemeColorToken[]
|
|
92
140
|
|
|
93
|
-
export function deriveThemeColors(
|
|
141
|
+
export function deriveThemeColors(
|
|
142
|
+
primary: string,
|
|
143
|
+
mode: ThemeColorMode = 'workspace'
|
|
144
|
+
): ThemeColors {
|
|
94
145
|
const colors = {} as ThemeColors
|
|
146
|
+
const derivations = THEME_COLOR_DERIVATIONS[mode]
|
|
95
147
|
for (const token of THEME_COLOR_TOKENS) {
|
|
96
|
-
colors[token] =
|
|
148
|
+
colors[token] = derivations[token](primary)
|
|
97
149
|
}
|
|
98
150
|
return colors
|
|
99
151
|
}
|
|
@@ -102,26 +154,46 @@ export const COLOR_THEMES: Record<ColorTheme, ColorThemeConfig> = {
|
|
|
102
154
|
default: { label: 'Default' },
|
|
103
155
|
paper: {
|
|
104
156
|
label: 'Paper',
|
|
105
|
-
primary: '
|
|
106
|
-
},
|
|
107
|
-
sand: {
|
|
108
|
-
label: 'Sand',
|
|
109
|
-
primary: '#ff8700'
|
|
157
|
+
primary: 'oklch(0.4328 0.0351 66.67)'
|
|
110
158
|
},
|
|
111
159
|
rose: {
|
|
112
160
|
label: 'Rose',
|
|
113
|
-
primary: '
|
|
161
|
+
primary: 'oklch(0.6322 0.2171 26.02)'
|
|
114
162
|
},
|
|
115
|
-
|
|
116
|
-
label: '
|
|
117
|
-
primary: '
|
|
163
|
+
tangerine: {
|
|
164
|
+
label: 'Tangerine',
|
|
165
|
+
primary: 'oklch(0.6886 0.22 37.15)'
|
|
166
|
+
},
|
|
167
|
+
sand: {
|
|
168
|
+
label: 'Sand',
|
|
169
|
+
primary: 'oklch(0.8334 0.1271 67.80)'
|
|
118
170
|
},
|
|
119
171
|
mint: {
|
|
120
172
|
label: 'Tropics',
|
|
121
|
-
primary: '
|
|
173
|
+
primary: 'oklch(0.5774 0.1399 156.06)'
|
|
122
174
|
},
|
|
123
175
|
sky: {
|
|
124
176
|
label: 'Sky',
|
|
125
|
-
primary: '
|
|
177
|
+
primary: 'oklch(0.5824 0.1830 253.59)'
|
|
178
|
+
},
|
|
179
|
+
lavender: {
|
|
180
|
+
label: 'Lavender',
|
|
181
|
+
primary: 'oklch(0.6025 0.2426 294.58)'
|
|
126
182
|
}
|
|
127
183
|
}
|
|
184
|
+
|
|
185
|
+
export type WorkspaceTheme = {
|
|
186
|
+
font: FontTheme
|
|
187
|
+
color: ColorTheme
|
|
188
|
+
radius: RadiusTheme
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export const DEFAULT_WORKSPACE_THEME: WorkspaceTheme = {
|
|
192
|
+
font: 'sans',
|
|
193
|
+
color: 'default',
|
|
194
|
+
radius: 'soft'
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export function resolveWorkspaceTheme(theme?: Partial<WorkspaceTheme>): WorkspaceTheme {
|
|
198
|
+
return { ...DEFAULT_WORKSPACE_THEME, ...theme }
|
|
199
|
+
}
|
package/lib/types.ts
CHANGED
|
@@ -503,7 +503,7 @@ export type WorkspaceTabsState = {
|
|
|
503
503
|
active: WorkspaceTabId
|
|
504
504
|
}
|
|
505
505
|
|
|
506
|
-
export type { FontTheme,
|
|
506
|
+
export type { ColorTheme, FontTheme, RadiusTheme, WorkspaceTheme } from './themes'
|
|
507
507
|
|
|
508
508
|
export type WorkspaceLayout = {
|
|
509
509
|
version: 1
|
|
@@ -533,10 +533,7 @@ export type WorkspaceLayout = {
|
|
|
533
533
|
selectedEffort?: string
|
|
534
534
|
// Fast-mode default for new sessions. Undefined inherits the provider setting.
|
|
535
535
|
selectedFastMode?: boolean
|
|
536
|
-
theme?:
|
|
537
|
-
font: import('./themes').FontTheme
|
|
538
|
-
primary?: string
|
|
539
|
-
}
|
|
536
|
+
theme?: import('./themes').WorkspaceTheme
|
|
540
537
|
// Widget thumbnails captured client-side from the live grid, used for
|
|
541
538
|
// home-screen previews. Saved through their own endpoint (PUT
|
|
542
539
|
// .../thumbnails), never through the layout PUT.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "moi-computer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
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",
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
"citty": "^0.2.1",
|
|
70
70
|
"class-variance-authority": "^0.7.1",
|
|
71
71
|
"clsx": "^2.1.1",
|
|
72
|
-
"colord": "^2.9.3",
|
|
73
72
|
"conf": "^15.1.0",
|
|
73
|
+
"culori": "^4.0.2",
|
|
74
74
|
"devalue": "^5.6.4",
|
|
75
75
|
"env-paths": "^4.0.0",
|
|
76
76
|
"frimousse": "^0.3.0",
|
|
@@ -94,8 +94,8 @@
|
|
|
94
94
|
"shadcn": "^4.13.0",
|
|
95
95
|
"sharp": "^0.35.1",
|
|
96
96
|
"sugar-high": "^1.2.1",
|
|
97
|
-
"tailwind-merge": "^3.
|
|
98
|
-
"tailwindcss": "^4.
|
|
97
|
+
"tailwind-merge": "^3.6.0",
|
|
98
|
+
"tailwindcss": "^4.3.3",
|
|
99
99
|
"tldraw": "5.2.3",
|
|
100
100
|
"tw-animate-css": "^1.4.0",
|
|
101
101
|
"typescript": "^5.9.3",
|
|
@@ -107,6 +107,7 @@
|
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
109
|
"@types/bun": "latest",
|
|
110
|
+
"@types/culori": "^4.0.1",
|
|
110
111
|
"@types/react": "^19",
|
|
111
112
|
"@types/react-dom": "^19",
|
|
112
113
|
"@types/react-grid-layout": "^2.1.0",
|
package/server/api.ts
CHANGED
|
@@ -36,7 +36,6 @@ import { getClientFrameLog, getWireLog } from './harness/debug'
|
|
|
36
36
|
import { allHarnesses, harnessFor, isHarnessType } from './harness/registry'
|
|
37
37
|
import { broadcast } from './state'
|
|
38
38
|
import {
|
|
39
|
-
discoverWorkspace,
|
|
40
39
|
discoverWorkspaces,
|
|
41
40
|
getWorkspace,
|
|
42
41
|
listWorkspaces,
|
|
@@ -933,14 +932,12 @@ async function harnessAvailability(): Promise<Record<string, HarnessAvailability
|
|
|
933
932
|
}
|
|
934
933
|
|
|
935
934
|
// Where `/workspace/create` places new folders — the client shows the resolved
|
|
936
|
-
// location while the user types a name. `
|
|
937
|
-
//
|
|
938
|
-
// lets the dialog disable backends whose runtime is missing.
|
|
935
|
+
// location while the user types a name. `availability` lets the dialog disable
|
|
936
|
+
// backends whose runtime is missing.
|
|
939
937
|
workspaces.get('/create', async c =>
|
|
940
938
|
c.json({
|
|
941
939
|
root: CREATED_WORKSPACES_ROOT,
|
|
942
940
|
displayRoot: tildify(CREATED_WORKSPACES_ROOT),
|
|
943
|
-
canChooseFolder: process.platform === 'darwin',
|
|
944
941
|
availability: await harnessAvailability()
|
|
945
942
|
})
|
|
946
943
|
)
|
|
@@ -976,74 +973,6 @@ workspaces.post('/create', async c => {
|
|
|
976
973
|
return c.json(entry, 201)
|
|
977
974
|
})
|
|
978
975
|
|
|
979
|
-
// Guards against opening a second native picker while one is already up — a
|
|
980
|
-
// duplicate request (e.g. a quick re-click) resolves as canceled instead of
|
|
981
|
-
// spawning a second Finder dialog on top of the first.
|
|
982
|
-
let folderPickerOpen = false
|
|
983
|
-
|
|
984
|
-
export function isSameOriginRequest(req: Request): boolean {
|
|
985
|
-
const site = req.headers.get('sec-fetch-site')
|
|
986
|
-
if (site === 'cross-site') return false
|
|
987
|
-
// Modern browsers state the relationship directly — trust it. Reaching the
|
|
988
|
-
// Origin fallback below with a full-origin comparison would 403 every request
|
|
989
|
-
// behind a TLS-terminating proxy (Cloudflare Tunnel, nginx, ngrok — see
|
|
990
|
-
// client/lib/ws-url.ts): the browser sends `https://…` while `req.url` is
|
|
991
|
-
// built from the plain-HTTP listener.
|
|
992
|
-
if (site === 'same-origin') return true
|
|
993
|
-
const origin = req.headers.get('origin')
|
|
994
|
-
if (!origin) return true
|
|
995
|
-
// Older browsers without sec-fetch-site: compare hosts only, since the
|
|
996
|
-
// scheme the browser saw is unknowable behind TLS termination.
|
|
997
|
-
try {
|
|
998
|
-
return new URL(origin).host === new URL(req.url).host
|
|
999
|
-
} catch {
|
|
1000
|
-
return false
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
// Open the OS-native folder picker so the user can choose an existing folder to
|
|
1005
|
-
// import (the create dialog's "Use existing folder"). The server runs on the
|
|
1006
|
-
// user's machine, so it can drive the real system dialog — the browser can't.
|
|
1007
|
-
// Returns the same grouped provider discovery shape as `/discover`, or
|
|
1008
|
-
// `{ canceled: true }` if the dialog is dismissed. macOS only for now.
|
|
1009
|
-
workspaces.post('/choose-folder', async c => {
|
|
1010
|
-
if (!isSameOriginRequest(c.req.raw)) return c.text('Forbidden', 403)
|
|
1011
|
-
if (process.platform !== 'darwin') {
|
|
1012
|
-
return c.text('Choosing a folder is only supported on macOS for now', 400)
|
|
1013
|
-
}
|
|
1014
|
-
if (folderPickerOpen) return c.json({ canceled: true })
|
|
1015
|
-
folderPickerOpen = true
|
|
1016
|
-
try {
|
|
1017
|
-
// The picker is spawned by osascript, a background helper, so macOS won't
|
|
1018
|
-
// give it focus by default. `tell me to activate` forces the script runner
|
|
1019
|
-
// frontmost, and the short delay lets that settle before the panel opens so
|
|
1020
|
-
// it appears focused rather than behind other windows.
|
|
1021
|
-
const proc = Bun.spawn(
|
|
1022
|
-
[
|
|
1023
|
-
'osascript',
|
|
1024
|
-
'-e',
|
|
1025
|
-
'tell me to activate',
|
|
1026
|
-
'-e',
|
|
1027
|
-
'delay 0.2',
|
|
1028
|
-
'-e',
|
|
1029
|
-
'POSIX path of (choose folder with prompt "Select a project folder")'
|
|
1030
|
-
],
|
|
1031
|
-
{ stdout: 'pipe', stderr: 'pipe' }
|
|
1032
|
-
)
|
|
1033
|
-
const exitCode = await proc.exited
|
|
1034
|
-
// osascript exits non-zero when the user presses Cancel.
|
|
1035
|
-
if (exitCode !== 0) return c.json({ canceled: true })
|
|
1036
|
-
const path = (await new Response(proc.stdout).text()).trim()
|
|
1037
|
-
if (!path) return c.json({ canceled: true })
|
|
1038
|
-
return c.json(await discoverWorkspace(path))
|
|
1039
|
-
} catch (err) {
|
|
1040
|
-
const message = err instanceof Error ? err.message : String(err)
|
|
1041
|
-
return c.text(`Could not open the folder picker: ${message}`, 500)
|
|
1042
|
-
} finally {
|
|
1043
|
-
folderPickerOpen = false
|
|
1044
|
-
}
|
|
1045
|
-
})
|
|
1046
|
-
|
|
1047
976
|
// `/:id` is registered after the static `/discover` so the literal path wins.
|
|
1048
977
|
// `/api/workspaces/ws` (the live-event WebSocket) is intercepted by Bun's routes
|
|
1049
978
|
// table before it ever reaches Hono, so it never collides with `:id`.
|
|
@@ -415,12 +415,11 @@ function appletRuntimePlugin(
|
|
|
415
415
|
return { plugin, serverModules, assets }
|
|
416
416
|
}
|
|
417
417
|
|
|
418
|
-
//
|
|
419
|
-
//
|
|
420
|
-
// theme tokens.
|
|
418
|
+
// Shared Tailwind input for applet bundles. It maps semantic tokens and
|
|
419
|
+
// provides the same texture utilities available to host components.
|
|
421
420
|
const HOST_THEME_PATH = join(import.meta.dir, '..', '..', 'client', 'theme.css')
|
|
422
421
|
|
|
423
|
-
// Three things matter for
|
|
422
|
+
// Three things matter for applet styling:
|
|
424
423
|
// 1. The umbrella `@import 'tailwindcss'` brings in @layer theme + base +
|
|
425
424
|
// utilities — which is what spacing/color utilities like `left-2.5`,
|
|
426
425
|
// `gap-1.5`, `text-amber-500` need to resolve. The split
|
|
@@ -433,6 +432,7 @@ const HOST_THEME_PATH = join(import.meta.dir, '..', '..', 'client', 'theme.css')
|
|
|
433
432
|
// means the widget's CSS does NOT redefine the underlying
|
|
434
433
|
// `--background`/`--foreground` variables — those stay host-owned and
|
|
435
434
|
// the widget picks them up from `:root` at runtime.
|
|
435
|
+
// The same shared file also defines texture utilities for both surfaces.
|
|
436
436
|
// 3. Tailwind's auto-detection treats `.moi/` as a hidden directory
|
|
437
437
|
// and skips it. An explicit `@source` bypasses the dot-dir + gitignore
|
|
438
438
|
// filters.
|
|
@@ -461,6 +461,9 @@ async function writeSyntheticTailwindCss(
|
|
|
461
461
|
// back to `@media (prefers-color-scheme: dark)`, which diverges from the
|
|
462
462
|
// host and injects OS-preference media queries into the page.
|
|
463
463
|
`@custom-variant dark (&:is(.dark *));`,
|
|
464
|
+
// Textures use their light-on-dark treatment in every widget, regardless
|
|
465
|
+
// of the widget's selected workspace color.
|
|
466
|
+
`@custom-variant dark-or-widget (&:is(.dark *, [data-widget-chrome] *));`,
|
|
464
467
|
`@source "${sourceDir}";`
|
|
465
468
|
].join('\n')
|
|
466
469
|
await Bun.write(cssPath, contents)
|
package/server/cli.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
import './cli-colors' // must precede citty: sets NO_COLOR before its color flag is computed
|
|
3
3
|
import { defineCommand, runMain, showUsage } from 'citty'
|
|
4
|
+
import { formatHex } from 'culori'
|
|
4
5
|
import { parse as devalueParse } from 'devalue'
|
|
5
6
|
import { existsSync } from 'node:fs'
|
|
6
7
|
import { tmpdir } from 'node:os'
|
|
@@ -9,8 +10,14 @@ import pc from './cli-pc'
|
|
|
9
10
|
|
|
10
11
|
import { isAgentCaller } from './agent-caller'
|
|
11
12
|
|
|
12
|
-
import {
|
|
13
|
-
|
|
13
|
+
import {
|
|
14
|
+
COLOR_THEMES,
|
|
15
|
+
DEFAULT_WORKSPACE_THEME,
|
|
16
|
+
FONT_THEMES,
|
|
17
|
+
RADIUS_THEMES,
|
|
18
|
+
deriveThemeColors
|
|
19
|
+
} from '@/lib/themes'
|
|
20
|
+
import type { ColorTheme, FontTheme, RadiusTheme } from '@/lib/themes'
|
|
14
21
|
import { isParamsRecord } from '@/lib/workspace-tabs'
|
|
15
22
|
import type {
|
|
16
23
|
AppletLogEntry,
|
|
@@ -678,9 +685,9 @@ const refresh = defineCommand({
|
|
|
678
685
|
}
|
|
679
686
|
})
|
|
680
687
|
|
|
681
|
-
function hexToRgb(
|
|
682
|
-
const
|
|
683
|
-
return [(
|
|
688
|
+
function hexToRgb(hex: string): [number, number, number] {
|
|
689
|
+
const value = Number.parseInt(hex.slice(1), 16)
|
|
690
|
+
return [(value >> 16) & 0xff, (value >> 8) & 0xff, value & 0xff]
|
|
684
691
|
}
|
|
685
692
|
|
|
686
693
|
// Truecolor swatch using raw ANSI 24-bit escapes (picocolors maxes at 8 colors).
|
|
@@ -695,11 +702,11 @@ function swatch(bg?: string, fg?: string): string {
|
|
|
695
702
|
function themeSwatch(primary?: string): string {
|
|
696
703
|
if (!primary) return swatch()
|
|
697
704
|
const colors = deriveThemeColors(primary)
|
|
698
|
-
return swatch(colors.primary, colors.primaryForeground)
|
|
705
|
+
return swatch(formatHex(colors.primary), formatHex(colors.primaryForeground))
|
|
699
706
|
}
|
|
700
707
|
|
|
701
708
|
const theme = defineCommand({
|
|
702
|
-
meta: { name: 'theme', description: 'Show or set the workspace
|
|
709
|
+
meta: { name: 'theme', description: 'Show or set the workspace appearance' },
|
|
703
710
|
args: {
|
|
704
711
|
dir: {
|
|
705
712
|
type: 'positional',
|
|
@@ -707,7 +714,8 @@ const theme = defineCommand({
|
|
|
707
714
|
description: 'Workspace directory (default: current)'
|
|
708
715
|
},
|
|
709
716
|
font: { type: 'string', description: 'Font theme key to apply' },
|
|
710
|
-
color: { type: 'string', description: 'Color preset key to apply' }
|
|
717
|
+
color: { type: 'string', description: 'Color preset key to apply' },
|
|
718
|
+
radius: { type: 'string', description: 'Radius preset key to apply' }
|
|
711
719
|
},
|
|
712
720
|
async run({ args }) {
|
|
713
721
|
const path = resolve(args.dir)
|
|
@@ -720,7 +728,8 @@ const theme = defineCommand({
|
|
|
720
728
|
type: 'theme',
|
|
721
729
|
path,
|
|
722
730
|
font: args.font ?? null,
|
|
723
|
-
color: args.color ?? null
|
|
731
|
+
color: args.color ?? null,
|
|
732
|
+
radius: args.radius ?? null
|
|
724
733
|
})
|
|
725
734
|
)
|
|
726
735
|
|
|
@@ -749,16 +758,21 @@ const theme = defineCommand({
|
|
|
749
758
|
const chip = themeSwatch(preset.primary)
|
|
750
759
|
console.log(pc.green('✓') + ' Color set to ' + pc.bold(preset.label) + ' ' + chip)
|
|
751
760
|
}
|
|
761
|
+
if (res.radius) {
|
|
762
|
+
const preset = RADIUS_THEMES[res.radius as RadiusTheme]
|
|
763
|
+
console.log(pc.green('✓') + ' Radius set to ' + pc.bold(preset.label))
|
|
764
|
+
}
|
|
752
765
|
console.log()
|
|
753
766
|
if (notice) console.log(pc.yellow(notice) + '\n')
|
|
754
767
|
ws.close()
|
|
755
768
|
process.exit(0)
|
|
756
769
|
}
|
|
757
770
|
|
|
758
|
-
const currentFont: FontTheme = res.currentFont ??
|
|
759
|
-
const currentColor: ColorTheme
|
|
771
|
+
const currentFont: FontTheme = res.currentFont ?? DEFAULT_WORKSPACE_THEME.font
|
|
772
|
+
const currentColor: ColorTheme = res.currentColor ?? DEFAULT_WORKSPACE_THEME.color
|
|
773
|
+
const currentRadius: RadiusTheme = res.currentRadius ?? DEFAULT_WORKSPACE_THEME.radius
|
|
760
774
|
console.log('\n' + pc.bold('moi theme') + ' — workspace appearance')
|
|
761
|
-
console.log(pc.dim(' Usage: moi theme --font=<key> --color=<key>') + '\n')
|
|
775
|
+
console.log(pc.dim(' Usage: moi theme --font=<key> --color=<key> --radius=<key>') + '\n')
|
|
762
776
|
|
|
763
777
|
const fontRows = (Object.keys(FONT_THEMES) as FontTheme[]).map(key => {
|
|
764
778
|
const f = FONT_THEMES[key]
|
|
@@ -768,14 +782,13 @@ const theme = defineCommand({
|
|
|
768
782
|
selected ? pc.bold(key) : key,
|
|
769
783
|
f.label,
|
|
770
784
|
pc.dim(f.sans),
|
|
771
|
-
pc.dim(f.mono)
|
|
772
|
-
pc.dim(f.feel)
|
|
785
|
+
pc.dim(f.mono)
|
|
773
786
|
]
|
|
774
787
|
})
|
|
775
788
|
console.log(pc.dim(' Fonts'))
|
|
776
789
|
console.log(
|
|
777
790
|
columns(
|
|
778
|
-
['', 'key', 'label', 'sans', 'mono'
|
|
791
|
+
['', 'key', 'label', 'sans', 'mono'].map(h => pc.dim(h)),
|
|
779
792
|
fontRows
|
|
780
793
|
) + '\n'
|
|
781
794
|
)
|
|
@@ -798,6 +811,24 @@ const theme = defineCommand({
|
|
|
798
811
|
) + '\n'
|
|
799
812
|
)
|
|
800
813
|
|
|
814
|
+
const radiusRows = (Object.keys(RADIUS_THEMES) as RadiusTheme[]).map(key => {
|
|
815
|
+
const radius = RADIUS_THEMES[key]
|
|
816
|
+
const selected = key === currentRadius
|
|
817
|
+
return [
|
|
818
|
+
selected ? pc.green('→') : ' ',
|
|
819
|
+
selected ? pc.bold(key) : key,
|
|
820
|
+
radius.label,
|
|
821
|
+
pc.dim(radius.radius)
|
|
822
|
+
]
|
|
823
|
+
})
|
|
824
|
+
console.log(pc.dim(' Radius'))
|
|
825
|
+
console.log(
|
|
826
|
+
columns(
|
|
827
|
+
['', 'key', 'label', 'value'].map(h => pc.dim(h)),
|
|
828
|
+
radiusRows
|
|
829
|
+
) + '\n'
|
|
830
|
+
)
|
|
831
|
+
|
|
801
832
|
if (notice) console.log(pc.yellow(notice) + '\n')
|
|
802
833
|
ws.close()
|
|
803
834
|
process.exit(0)
|
package/server/control.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { stringify as devalueStringify } from 'devalue'
|
|
2
2
|
import { resolve } from 'path'
|
|
3
3
|
|
|
4
|
+
import { resolveWorkspaceTheme } from '@/lib/themes'
|
|
4
5
|
import type { WorkspaceEntry } from '@/lib/types'
|
|
5
6
|
import { isParamsRecord } from '@/lib/workspace-tabs'
|
|
6
7
|
|
|
@@ -18,7 +19,7 @@ import { readScratchpadImage, readScratchpadShapes } from './scratchpad'
|
|
|
18
19
|
import { relayScratchOp } from './scratchpad-relay'
|
|
19
20
|
import { broadcastAll } from './state'
|
|
20
21
|
import { assembleTabRows, resolveFocusTab } from './tabs'
|
|
21
|
-
import { applyThemeUpdate
|
|
22
|
+
import { applyThemeUpdate } from './theme'
|
|
22
23
|
import { handleBundle } from './widgets'
|
|
23
24
|
import { getViewList, handleBundleViews, hasViewId } from './views'
|
|
24
25
|
import {
|
|
@@ -353,18 +354,24 @@ export const control = Bun.serve({
|
|
|
353
354
|
const workspacePath = match.path
|
|
354
355
|
const layout = await loadLayout(workspacePath)
|
|
355
356
|
|
|
356
|
-
// Listing mode —
|
|
357
|
-
if (!data.font && !data.color) {
|
|
357
|
+
// Listing mode — no theme setting requested
|
|
358
|
+
if (!data.font && !data.color && !data.radius) {
|
|
359
|
+
const theme = resolveWorkspaceTheme(layout.theme)
|
|
358
360
|
ws.send(
|
|
359
361
|
JSON.stringify({
|
|
360
|
-
currentFont:
|
|
361
|
-
currentColor:
|
|
362
|
+
currentFont: theme.font,
|
|
363
|
+
currentColor: theme.color,
|
|
364
|
+
currentRadius: theme.radius
|
|
362
365
|
})
|
|
363
366
|
)
|
|
364
367
|
return
|
|
365
368
|
}
|
|
366
369
|
|
|
367
|
-
const result = applyThemeUpdate(layout.theme, {
|
|
370
|
+
const result = applyThemeUpdate(layout.theme, {
|
|
371
|
+
font: data.font,
|
|
372
|
+
color: data.color,
|
|
373
|
+
radius: data.radius
|
|
374
|
+
})
|
|
368
375
|
if (!result.ok) {
|
|
369
376
|
ws.send(JSON.stringify({ error: result.error }))
|
|
370
377
|
return
|
package/server/moi-scaffold.ts
CHANGED
package/server/registry.ts
CHANGED
|
@@ -173,19 +173,6 @@ export function groupDiscoveredWorkspaces(
|
|
|
173
173
|
}))
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
export function discoveredWorkspaceForPath(
|
|
177
|
-
path: string,
|
|
178
|
-
candidates: DiscoveredWorkspaceCandidate[]
|
|
179
|
-
): DiscoveredWorkspace {
|
|
180
|
-
const normalizedPath = resolve(path)
|
|
181
|
-
return (
|
|
182
|
-
groupDiscoveredWorkspaces(candidates).find(workspace => workspace.path === normalizedPath) ?? {
|
|
183
|
-
path: normalizedPath,
|
|
184
|
-
types: []
|
|
185
|
-
}
|
|
186
|
-
)
|
|
187
|
-
}
|
|
188
|
-
|
|
189
176
|
// Ask every harness for workspaces it knows about that aren't registered yet,
|
|
190
177
|
// then combine providers that claim the same normalized folder.
|
|
191
178
|
export async function discoverWorkspaces(): Promise<DiscoveredWorkspace[]> {
|
|
@@ -193,10 +180,3 @@ export async function discoverWorkspaces(): Promise<DiscoveredWorkspace[]> {
|
|
|
193
180
|
const found = await collectDiscoveredWorkspaces(registeredPaths)
|
|
194
181
|
return groupDiscoveredWorkspaces(found, registeredPaths).map(withDisplayPath)
|
|
195
182
|
}
|
|
196
|
-
|
|
197
|
-
// Inspect one folder through the same provider discovery used by the home
|
|
198
|
-
// suggestions. An empty types list means no provider recognized the folder.
|
|
199
|
-
export async function discoverWorkspace(path: string): Promise<DiscoveredWorkspace> {
|
|
200
|
-
const found = await collectDiscoveredWorkspaces(new Set())
|
|
201
|
-
return withDisplayPath(discoveredWorkspaceForPath(path, found))
|
|
202
|
-
}
|