@workbench-kit/adapters 0.0.1-prototype.0 → 0.0.2-prototype.0.1.1

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.
@@ -0,0 +1,328 @@
1
+ import type { WorkspaceFile } from '@workbench-kit/workspace';
2
+
3
+ import {
4
+ flattenWidgetStudioAssetPackages,
5
+ WIDGET_STUDIO_ASSETS_DIR,
6
+ WIDGET_STUDIO_CUSTOM_ASSETS_DIR,
7
+ type WidgetStudioAssetPackageDefinition,
8
+ } from './widget-studio-asset-package.js';
9
+
10
+ export { WIDGET_STUDIO_ASSETS_DIR, WIDGET_STUDIO_CUSTOM_ASSETS_DIR };
11
+
12
+ export type WidgetStudioWorkspaceAssetFile = WorkspaceFile;
13
+
14
+ const TEXT_INPUTS_SCHEMA = {
15
+ $schema: 'http://json-schema.org/draft-07/schema#',
16
+ title: 'TextAssetInputs',
17
+ type: 'object',
18
+ properties: {
19
+ text: { type: 'string' },
20
+ fontSize: { type: 'number', minimum: 1 },
21
+ color: { type: 'string' },
22
+ },
23
+ };
24
+
25
+ const LAYOUT_INPUTS_SCHEMA = {
26
+ $schema: 'http://json-schema.org/draft-07/schema#',
27
+ title: 'LayoutAssetInputs',
28
+ type: 'object',
29
+ properties: {
30
+ gap: { type: 'number', minimum: 0, default: 8 },
31
+ padding: { type: 'number', minimum: 0, default: 0 },
32
+ },
33
+ };
34
+
35
+ const builtinAssetPackages: WidgetStudioAssetPackageDefinition[] = [
36
+ {
37
+ slug: 'heading',
38
+ updatedAt: '2026-06-02T09:24:00.000Z',
39
+ manifest: {
40
+ name: 'content.heading',
41
+ version: '1.0.0',
42
+ label: 'Heading',
43
+ description: 'Large title text',
44
+ category: 'content',
45
+ kind: 'leaf',
46
+ icon: 'codicon-symbol-text',
47
+ },
48
+ schema: TEXT_INPUTS_SCHEMA,
49
+ content: {
50
+ type: 'text',
51
+ args: { text: 'Heading', fontSize: 24 },
52
+ },
53
+ },
54
+ {
55
+ slug: 'body',
56
+ updatedAt: '2026-06-02T09:24:10.000Z',
57
+ manifest: {
58
+ name: 'content.body',
59
+ version: '1.0.0',
60
+ label: 'Body',
61
+ description: 'Default paragraph text',
62
+ category: 'content',
63
+ kind: 'leaf',
64
+ icon: 'codicon-whole-word',
65
+ },
66
+ schema: TEXT_INPUTS_SCHEMA,
67
+ content: {
68
+ type: 'text',
69
+ args: { text: 'Body text' },
70
+ },
71
+ },
72
+ {
73
+ slug: 'label',
74
+ updatedAt: '2026-06-02T09:24:12.000Z',
75
+ manifest: {
76
+ name: 'content.label',
77
+ version: '1.0.0',
78
+ label: 'Label',
79
+ description: 'Small muted label',
80
+ category: 'content',
81
+ kind: 'leaf',
82
+ icon: 'codicon-tag',
83
+ },
84
+ schema: TEXT_INPUTS_SCHEMA,
85
+ content: {
86
+ type: 'text',
87
+ args: { text: 'Label', fontSize: 12, color: '#9aa0a6' },
88
+ },
89
+ },
90
+ {
91
+ slug: 'caption',
92
+ updatedAt: '2026-06-02T09:24:14.000Z',
93
+ manifest: {
94
+ name: 'content.caption',
95
+ version: '1.0.0',
96
+ label: 'Caption',
97
+ description: 'Secondary supporting text',
98
+ category: 'content',
99
+ kind: 'leaf',
100
+ icon: 'codicon-info',
101
+ },
102
+ schema: TEXT_INPUTS_SCHEMA,
103
+ content: {
104
+ type: 'text',
105
+ args: { text: 'Caption', fontSize: 11, color: '#7a7f87' },
106
+ },
107
+ },
108
+ {
109
+ slug: 'row',
110
+ updatedAt: '2026-06-02T09:24:20.000Z',
111
+ manifest: {
112
+ name: 'layout.row',
113
+ version: '1.0.0',
114
+ label: 'Row',
115
+ description: 'Horizontal flex container',
116
+ category: 'layout',
117
+ kind: 'container',
118
+ icon: 'codicon-arrow-right',
119
+ },
120
+ schema: LAYOUT_INPUTS_SCHEMA,
121
+ content: {
122
+ type: 'row',
123
+ args: { gap: 8, padding: 0, children: [] },
124
+ },
125
+ },
126
+ {
127
+ slug: 'column',
128
+ updatedAt: '2026-06-02T09:24:22.000Z',
129
+ manifest: {
130
+ name: 'layout.column',
131
+ version: '1.0.0',
132
+ label: 'Column',
133
+ description: 'Vertical flex container',
134
+ category: 'layout',
135
+ kind: 'container',
136
+ icon: 'codicon-arrow-down',
137
+ },
138
+ schema: LAYOUT_INPUTS_SCHEMA,
139
+ content: {
140
+ type: 'column',
141
+ args: { gap: 8, padding: 0, children: [] },
142
+ },
143
+ },
144
+ {
145
+ slug: 'grid-2',
146
+ updatedAt: '2026-06-02T09:24:30.000Z',
147
+ manifest: {
148
+ name: 'layout.grid-2',
149
+ version: '1.0.0',
150
+ label: '2-col Grid',
151
+ description: 'Two column grid',
152
+ category: 'layout',
153
+ kind: 'container',
154
+ icon: 'codicon-layout',
155
+ },
156
+ schema: {
157
+ ...LAYOUT_INPUTS_SCHEMA,
158
+ properties: {
159
+ ...LAYOUT_INPUTS_SCHEMA.properties,
160
+ columns: { type: 'number', minimum: 1, default: 2 },
161
+ },
162
+ },
163
+ content: {
164
+ type: 'grid',
165
+ args: { columns: 2, gap: 8, padding: 0, children: [] },
166
+ },
167
+ },
168
+ {
169
+ slug: 'grid-3',
170
+ updatedAt: '2026-06-02T09:24:32.000Z',
171
+ manifest: {
172
+ name: 'layout.grid-3',
173
+ version: '1.0.0',
174
+ label: '3-col Grid',
175
+ description: 'Three column grid',
176
+ category: 'layout',
177
+ kind: 'container',
178
+ icon: 'codicon-layout',
179
+ },
180
+ schema: {
181
+ ...LAYOUT_INPUTS_SCHEMA,
182
+ properties: {
183
+ ...LAYOUT_INPUTS_SCHEMA.properties,
184
+ columns: { type: 'number', minimum: 1, default: 3 },
185
+ },
186
+ },
187
+ content: {
188
+ type: 'grid',
189
+ args: { columns: 3, gap: 8, padding: 0, children: [] },
190
+ },
191
+ },
192
+ {
193
+ slug: 'media-card',
194
+ updatedAt: '2026-06-02T09:24:36.000Z',
195
+ manifest: {
196
+ name: 'template.media-card',
197
+ version: '1.0.0',
198
+ label: 'Media Card',
199
+ description: 'Image placeholder with title and caption',
200
+ category: 'template',
201
+ kind: 'template',
202
+ icon: 'codicon-file-media',
203
+ },
204
+ schema: {
205
+ $schema: 'http://json-schema.org/draft-07/schema#',
206
+ title: 'MediaCardInputs',
207
+ type: 'object',
208
+ properties: {
209
+ title: { type: 'string', default: 'Card title' },
210
+ description: { type: 'string', default: 'Short description for the card.' },
211
+ },
212
+ },
213
+ content: {
214
+ type: 'column',
215
+ args: {
216
+ gap: 8,
217
+ children: [
218
+ {
219
+ type: 'row',
220
+ args: {
221
+ gap: 0,
222
+ children: [
223
+ {
224
+ type: 'expanded',
225
+ args: {
226
+ flex: 1,
227
+ child: {
228
+ type: 'text',
229
+ args: { text: ' ', background: '#2b2f36' },
230
+ },
231
+ },
232
+ },
233
+ ],
234
+ },
235
+ },
236
+ {
237
+ type: 'text',
238
+ args: { text: 'Card title', fontSize: 16 },
239
+ },
240
+ {
241
+ type: 'text',
242
+ args: {
243
+ text: 'Short description for the card.',
244
+ fontSize: 12,
245
+ color: '#9aa0a6',
246
+ },
247
+ },
248
+ ],
249
+ },
250
+ },
251
+ },
252
+ {
253
+ slug: 'section-stack',
254
+ updatedAt: '2026-06-02T09:24:40.000Z',
255
+ manifest: {
256
+ name: 'template.section-stack',
257
+ version: '1.0.0',
258
+ label: 'Section Stack',
259
+ description: 'Title with supporting body copy',
260
+ category: 'template',
261
+ kind: 'template',
262
+ icon: 'codicon-layers',
263
+ },
264
+ schema: {
265
+ $schema: 'http://json-schema.org/draft-07/schema#',
266
+ title: 'SectionStackInputs',
267
+ type: 'object',
268
+ properties: {
269
+ title: { type: 'string', default: 'Section title' },
270
+ body: { type: 'string', default: 'Supporting body copy.' },
271
+ },
272
+ },
273
+ content: {
274
+ type: 'column',
275
+ args: {
276
+ gap: 4,
277
+ children: [
278
+ { type: 'text', args: { text: 'Section title', fontSize: 18 } },
279
+ { type: 'text', args: { text: 'Supporting body copy.' } },
280
+ ],
281
+ },
282
+ },
283
+ },
284
+ ];
285
+
286
+ const customAssetPackages: WidgetStudioAssetPackageDefinition[] = [
287
+ {
288
+ slug: 'feature-badge',
289
+ baseDir: WIDGET_STUDIO_CUSTOM_ASSETS_DIR,
290
+ updatedAt: '2026-06-02T09:25:00.000Z',
291
+ manifest: {
292
+ name: 'custom.feature-badge',
293
+ version: '1.0.0',
294
+ label: 'Feature Badge',
295
+ description: 'Custom workspace asset example',
296
+ category: 'content',
297
+ kind: 'template',
298
+ icon: 'codicon-verified',
299
+ },
300
+ schema: {
301
+ $schema: 'http://json-schema.org/draft-07/schema#',
302
+ title: 'FeatureBadgeInputs',
303
+ type: 'object',
304
+ properties: {
305
+ label: { type: 'string', default: 'Feature enabled' },
306
+ },
307
+ },
308
+ content: {
309
+ type: 'row',
310
+ args: {
311
+ gap: 6,
312
+ children: [
313
+ { type: 'text', args: { text: '✓', fontSize: 12, color: '#34a853' } },
314
+ { type: 'text', args: { text: 'Feature enabled', fontSize: 12 } },
315
+ ],
316
+ },
317
+ },
318
+ },
319
+ ];
320
+
321
+ export const widgetStudioBuiltinAssetFiles = flattenWidgetStudioAssetPackages(builtinAssetPackages);
322
+ export const widgetStudioCustomAssetExampleFiles =
323
+ flattenWidgetStudioAssetPackages(customAssetPackages);
324
+
325
+ export const widgetStudioAssetPackageSlugs = [
326
+ ...builtinAssetPackages.map((pkg) => pkg.slug),
327
+ ...customAssetPackages.map((pkg) => `${pkg.baseDir?.split('/').pop()}/${pkg.slug}`),
328
+ ];
@@ -0,0 +1,65 @@
1
+ import type { RuntimeStatus } from '@workbench-kit/runtime';
2
+
3
+ export type IntegratedShellActivityId = 'explorer' | 'search' | 'chat';
4
+
5
+ export const integratedShellActivityOrder: IntegratedShellActivityId[] = [
6
+ 'explorer',
7
+ 'search',
8
+ 'chat',
9
+ ];
10
+
11
+ export const integratedShellActivityLabels: Record<IntegratedShellActivityId, string> = {
12
+ explorer: 'Explorer',
13
+ search: 'Search',
14
+ chat: 'Chat',
15
+ };
16
+
17
+ const integratedShellActivityIcons: Record<IntegratedShellActivityId, string> = {
18
+ explorer: 'codicon-files',
19
+ search: 'codicon-search',
20
+ chat: 'codicon-comment-discussion',
21
+ };
22
+
23
+ export const integratedShellCommandActivities = integratedShellActivityOrder.map((id) => ({
24
+ id,
25
+ label: integratedShellActivityLabels[id],
26
+ icon: integratedShellActivityIcons[id],
27
+ }));
28
+
29
+ export function isIntegratedShellActivityId(id: string): id is IntegratedShellActivityId {
30
+ return id === 'explorer' || id === 'search' || id === 'chat';
31
+ }
32
+
33
+ export interface IntegratedShellBootstrapInitialState {
34
+ activeActivityId: IntegratedShellActivityId;
35
+ isPrimarySidebarVisible: boolean;
36
+ primarySidebarSizePercent: number;
37
+ primarySidebarMinPercent: number;
38
+ primarySidebarMaxPercent: number;
39
+ settingsCategoryId: string;
40
+ settingsScopeId: string;
41
+ theme: 'dark' | 'light';
42
+ }
43
+
44
+ export function createIntegratedShellBootstrapInitialState(
45
+ overrides: Partial<IntegratedShellBootstrapInitialState> = {},
46
+ ): IntegratedShellBootstrapInitialState {
47
+ return {
48
+ activeActivityId: 'explorer',
49
+ isPrimarySidebarVisible: true,
50
+ primarySidebarSizePercent: 20,
51
+ primarySidebarMinPercent: 16,
52
+ primarySidebarMaxPercent: 40,
53
+ settingsCategoryId: 'appearance',
54
+ settingsScopeId: 'user',
55
+ theme: 'dark',
56
+ ...overrides,
57
+ };
58
+ }
59
+
60
+ export function runtimeStatusLabel(status: RuntimeStatus): string {
61
+ if (status === 'running') return 'Runtime running';
62
+ if (status === 'cancelled') return 'Runtime stopped';
63
+ if (status === 'error') return 'Runtime error';
64
+ return 'Runtime idle';
65
+ }
@@ -0,0 +1,244 @@
1
+ import type { RuntimeChatMessage } from '@workbench-kit/runtime';
2
+ import type { WorkspaceFile } from '@workbench-kit/workspace';
3
+
4
+ import {
5
+ widgetStudioBuiltinAssetFiles,
6
+ widgetStudioCustomAssetExampleFiles,
7
+ } from './widget-studio-assets.js';
8
+
9
+ export const integratedShellWorkspaceFolders = [
10
+ 'src',
11
+ 'src/components',
12
+ 'src/workbench',
13
+ 'src/widgets',
14
+ 'src/widgets/assets',
15
+ 'src/widgets/assets/heading',
16
+ 'src/widgets/assets/body',
17
+ 'src/widgets/assets/label',
18
+ 'src/widgets/assets/caption',
19
+ 'src/widgets/assets/row',
20
+ 'src/widgets/assets/column',
21
+ 'src/widgets/assets/grid-2',
22
+ 'src/widgets/assets/grid-3',
23
+ 'src/widgets/assets/media-card',
24
+ 'src/widgets/assets/section-stack',
25
+ 'src/widgets/assets/custom',
26
+ 'src/widgets/assets/custom/feature-badge',
27
+ 'docs',
28
+ 'public',
29
+ ] as const;
30
+
31
+ const integratedShellCoreWorkspaceFiles: WorkspaceFile[] = [
32
+ {
33
+ path: 'src/App.tsx',
34
+ mimeType: 'application/typescript',
35
+ updatedAt: '2026-06-02T09:12:00.000Z',
36
+ source: 'user',
37
+ content: `import { WorkbenchShell } from './workbench/Shell';
38
+
39
+ export function App() {
40
+ return <WorkbenchShell title="Public UI Workbench" />;
41
+ }
42
+ `,
43
+ },
44
+ {
45
+ path: 'src/components/Button.tsx',
46
+ mimeType: 'application/typescript',
47
+ updatedAt: '2026-06-02T09:18:00.000Z',
48
+ source: 'assistant',
49
+ content: `import type { ComponentPropsWithRef } from 'react';
50
+
51
+ type ButtonVariant = 'default' | 'primary' | 'danger';
52
+
53
+ interface ButtonProps extends ComponentPropsWithRef<'button'> {
54
+ variant?: ButtonVariant;
55
+ }
56
+
57
+ export function Button({ variant = 'default', ...props }: ButtonProps) {
58
+ return <button data-variant={variant} {...props} />;
59
+ }
60
+ `,
61
+ },
62
+ {
63
+ path: 'src/components/Panel.tsx',
64
+ mimeType: 'application/typescript',
65
+ updatedAt: '2026-06-02T09:20:00.000Z',
66
+ source: 'assistant',
67
+ content: `import type { ComponentPropsWithRef, ReactNode } from 'react';
68
+
69
+ interface PanelProps extends ComponentPropsWithRef<'section'> {
70
+ title: ReactNode;
71
+ }
72
+
73
+ export function Panel({ children, title, ...props }: PanelProps) {
74
+ return (
75
+ <section {...props}>
76
+ <header>{title}</header>
77
+ <div>{children}</div>
78
+ </section>
79
+ );
80
+ }
81
+ `,
82
+ },
83
+ {
84
+ path: 'src/widgets/home.widget.json',
85
+ mimeType: 'application/vnd.workbench-kit.widget+json',
86
+ updatedAt: '2026-06-02T09:28:00.000Z',
87
+ source: 'user',
88
+ content: `{
89
+ "type": "column",
90
+ "args": {
91
+ "children": [
92
+ {
93
+ "type": "text",
94
+ "args": {
95
+ "text": "Welcome"
96
+ }
97
+ }
98
+ ]
99
+ }
100
+ }
101
+ `,
102
+ },
103
+ {
104
+ path: 'src/workbench/Shell.tsx',
105
+ mimeType: 'application/typescript',
106
+ updatedAt: '2026-06-02T09:30:00.000Z',
107
+ source: 'assistant',
108
+ content: `import { ActivityBar, StatusBar } from '@workbench-kit/react/workbench';
109
+
110
+ export function WorkbenchShell({ title }: { title: string }) {
111
+ return (
112
+ <main aria-label={title}>
113
+ <ActivityBar items={[]} />
114
+ <section data-region="editor">
115
+ <h1>{title}</h1>
116
+ </section>
117
+ <StatusBar compact />
118
+ </main>
119
+ );
120
+ }
121
+ `,
122
+ },
123
+ {
124
+ path: 'src/workbench/search.ts',
125
+ mimeType: 'application/typescript',
126
+ updatedAt: '2026-06-02T09:34:00.000Z',
127
+ source: 'assistant',
128
+ content: `export function compactText(value: string) {
129
+ return value.replace(/\\s+/g, ' ').trim();
130
+ }
131
+
132
+ export function createContentPreview(content: string, query: string) {
133
+ const compact = compactText(content);
134
+ const index = compact.toLowerCase().indexOf(query.toLowerCase());
135
+ if (index < 0) return compact.slice(0, 120);
136
+
137
+ const start = Math.max(0, index - 48);
138
+ const end = Math.min(compact.length, index + query.length + 72);
139
+ return \`\${start > 0 ? '...' : ''}\${compact.slice(start, end)}\${end < compact.length ? '...' : ''}\`;
140
+ }
141
+ `,
142
+ },
143
+ {
144
+ path: 'docs/getting-started.md',
145
+ mimeType: 'text/markdown',
146
+ updatedAt: '2026-06-02T09:42:00.000Z',
147
+ source: 'user',
148
+ content: `# Getting Started
149
+
150
+ Import shared styles once, then compose the workbench primitives in your app shell.
151
+
152
+ - Use Explorer for file navigation.
153
+ - Use Search for path and content matches.
154
+ - Use Chat for workspace-side conversations.
155
+ `,
156
+ },
157
+ {
158
+ path: 'package.json',
159
+ mimeType: 'application/json',
160
+ updatedAt: '2026-06-02T09:50:00.000Z',
161
+ source: 'user',
162
+ content: `{
163
+ "name": "@example/workbench-app",
164
+ "private": true,
165
+ "scripts": {
166
+ "storybook": "storybook dev --port 6010"
167
+ }
168
+ }
169
+ `,
170
+ },
171
+ {
172
+ path: 'public/theme.css',
173
+ mimeType: 'text/css',
174
+ updatedAt: '2026-06-02T09:54:00.000Z',
175
+ source: 'assistant',
176
+ content: `:root {
177
+ color-scheme: dark;
178
+ --workspace-accent: #4aa8ff;
179
+ }
180
+
181
+ .workspace-file-icon {
182
+ color: var(--workspace-accent);
183
+ }
184
+ `,
185
+ },
186
+ ];
187
+
188
+ export const integratedShellWorkspaceFiles: WorkspaceFile[] = [
189
+ ...integratedShellCoreWorkspaceFiles,
190
+ ...widgetStudioBuiltinAssetFiles,
191
+ ...widgetStudioCustomAssetExampleFiles,
192
+ ];
193
+
194
+ export {
195
+ widgetStudioBuiltinAssetFiles,
196
+ widgetStudioCustomAssetExampleFiles,
197
+ } from './widget-studio-assets.js';
198
+
199
+ export const integratedShellInitialRuntimeMessages: RuntimeChatMessage[] = [
200
+ {
201
+ id: 'm1',
202
+ source: 'user',
203
+ content:
204
+ 'Check whether the workbench shell covers explorer, search, chat, settings, and status surfaces.',
205
+ },
206
+ {
207
+ id: 'm2',
208
+ source: 'assistant',
209
+ content:
210
+ 'The integrated story now keeps those surfaces in one stateful shell with public mock data.',
211
+ },
212
+ {
213
+ id: 'm3',
214
+ source: 'assistant',
215
+ content:
216
+ 'Search results, file icons, and the editor preview are driven by the same virtual workspace.',
217
+ },
218
+ ];
219
+
220
+ export const integratedShellDefaultSelectionByActivity = {
221
+ explorer: 'src/App.tsx',
222
+ search: 'src/components/Button.tsx',
223
+ chat: 'src/App.tsx',
224
+ } as const;
225
+
226
+ export function createIntegratedShellChatRuntimeResponse(message: RuntimeChatMessage) {
227
+ return {
228
+ chunks: [
229
+ 'Mock runtime received the workspace request. ',
230
+ 'A workspace patch is ready in `docs/runtime-notes.md`.',
231
+ ],
232
+ intervalMs: 20,
233
+ workspacePatches: [
234
+ {
235
+ content: `# Runtime Notes\n\nLast request: ${message.content}\n\nThis file was produced by the public mock runtime fixture.\n`,
236
+ mimeType: 'text/markdown',
237
+ path: 'docs/runtime-notes.md',
238
+ source: 'assistant' as const,
239
+ type: 'write-file' as const,
240
+ updatedAt: '2026-06-02T10:05:00.000Z',
241
+ },
242
+ ],
243
+ };
244
+ }