@happyvertical/smrt-workbench 0.40.66
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/AGENTS.md +28 -0
- package/CLAUDE.md +1 -0
- package/LICENSE +7 -0
- package/README.md +31 -0
- package/dist/chunks/discovery-G9-foyW8.js +979 -0
- package/dist/chunks/discovery-G9-foyW8.js.map +1 -0
- package/dist/chunks/runtime-BTiu5fuP.js +93 -0
- package/dist/chunks/runtime-BTiu5fuP.js.map +1 -0
- package/dist/discovery.d.ts +14 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/runtime.d.ts +10 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +2 -0
- package/dist/svelte/MarkdownDocument.svelte +200 -0
- package/dist/svelte/MarkdownDocument.svelte.d.ts +7 -0
- package/dist/svelte/MarkdownDocument.svelte.d.ts.map +1 -0
- package/dist/svelte/WorkbenchHost.svelte +2058 -0
- package/dist/svelte/WorkbenchHost.svelte.d.ts +13 -0
- package/dist/svelte/WorkbenchHost.svelte.d.ts.map +1 -0
- package/dist/svelte/command.d.ts +6 -0
- package/dist/svelte/command.d.ts.map +1 -0
- package/dist/svelte/command.js +18 -0
- package/dist/svelte/index.d.ts +2 -0
- package/dist/svelte/index.d.ts.map +1 -0
- package/dist/svelte/index.js +1 -0
- package/dist/types.d.ts +202 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +0 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/vite.d.ts +6 -0
- package/dist/vite.d.ts.map +1 -0
- package/dist/vite.js +124 -0
- package/dist/vite.js.map +1 -0
- package/host/README.md +12 -0
- package/host/package.json +21 -0
- package/host/src/app.html +11 -0
- package/host/src/hooks.client.ts +5 -0
- package/host/src/routes/+error.svelte +44 -0
- package/host/src/routes/+page.svelte +15 -0
- package/host/svelte.config.js +12 -0
- package/host/tsconfig.json +10 -0
- package/host/vite.config.ts +202 -0
- package/package.json +96 -0
- package/src/discovery.ts +1748 -0
- package/src/runtime.ts +165 -0
- package/src/types.ts +243 -0
- package/src/utils.ts +16 -0
- package/src/vite.ts +303 -0
package/src/runtime.ts
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ResolvedWorkbenchModule,
|
|
3
|
+
ResolvedWorkbenchRouteEntry,
|
|
4
|
+
SmrtWorkbenchModule,
|
|
5
|
+
SmrtWorkbenchModuleExport,
|
|
6
|
+
SmrtWorkbenchRouteModule,
|
|
7
|
+
} from './types.js';
|
|
8
|
+
import { displayNameForSmrtPackage } from './utils.js';
|
|
9
|
+
|
|
10
|
+
export type {
|
|
11
|
+
ResolvedWorkbenchModule,
|
|
12
|
+
ResolvedWorkbenchRouteEntry,
|
|
13
|
+
SmrtWorkbenchModule,
|
|
14
|
+
SmrtWorkbenchModuleExport,
|
|
15
|
+
SmrtWorkbenchRouteDefinition,
|
|
16
|
+
SmrtWorkbenchRouteModule,
|
|
17
|
+
} from './types.js';
|
|
18
|
+
|
|
19
|
+
export function defineWorkbenchModule(
|
|
20
|
+
module: SmrtWorkbenchModule,
|
|
21
|
+
): SmrtWorkbenchModule {
|
|
22
|
+
return module;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function coerceWorkbenchModules(
|
|
26
|
+
input: SmrtWorkbenchModuleExport | null | undefined,
|
|
27
|
+
): SmrtWorkbenchModule[] {
|
|
28
|
+
if (!input) {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (Array.isArray(input)) {
|
|
33
|
+
return input.filter(Boolean);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if ('modules' in input && Array.isArray(input.modules)) {
|
|
37
|
+
return input.modules.filter(Boolean);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return [input as SmrtWorkbenchModule];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function collectRouteModules(
|
|
44
|
+
module: SmrtWorkbenchModule,
|
|
45
|
+
): SmrtWorkbenchRouteModule[] {
|
|
46
|
+
return [
|
|
47
|
+
...(module.routeModule ? [module.routeModule] : []),
|
|
48
|
+
...(module.routeModules || []),
|
|
49
|
+
].filter(Boolean);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function qualifyWorkbenchRouteId(
|
|
53
|
+
packageName: string,
|
|
54
|
+
routeId: string,
|
|
55
|
+
): string {
|
|
56
|
+
return `${packageName}:${routeId}`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function workbenchRouteHash(routeId: string): string {
|
|
60
|
+
return `#${routeId.replace(/[^a-zA-Z0-9_-]+/g, '-')}`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function findWorkbenchRouteByHash(
|
|
64
|
+
routes: ResolvedWorkbenchRouteEntry[],
|
|
65
|
+
hash: string,
|
|
66
|
+
): ResolvedWorkbenchRouteEntry | null {
|
|
67
|
+
if (!hash.startsWith('#')) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
let fragment: string;
|
|
72
|
+
try {
|
|
73
|
+
fragment = decodeURIComponent(hash.slice(1));
|
|
74
|
+
} catch {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
return (
|
|
78
|
+
routes.find(
|
|
79
|
+
(route) =>
|
|
80
|
+
fragment === route.id ||
|
|
81
|
+
fragment === route.qualifiedId ||
|
|
82
|
+
`#${fragment}` === workbenchRouteHash(route.id),
|
|
83
|
+
) || null
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function normalizeWorkbenchModule(
|
|
88
|
+
module: SmrtWorkbenchModule,
|
|
89
|
+
): ResolvedWorkbenchModule {
|
|
90
|
+
const displayName =
|
|
91
|
+
module.displayName || displayNameForSmrtPackage(module.packageName);
|
|
92
|
+
const routeModules = collectRouteModules(module);
|
|
93
|
+
const routes: ResolvedWorkbenchRouteEntry[] = routeModules
|
|
94
|
+
.flatMap((routeModule) => {
|
|
95
|
+
const moduleDisplayName = routeModule.displayName || displayName;
|
|
96
|
+
|
|
97
|
+
return Object.entries(routeModule.routes || {}).map(
|
|
98
|
+
([routeKey, route]) => {
|
|
99
|
+
const routeId = route.id || routeKey;
|
|
100
|
+
return {
|
|
101
|
+
...route,
|
|
102
|
+
packageName: routeModule.packageName || module.packageName,
|
|
103
|
+
moduleDisplayName,
|
|
104
|
+
routeKey,
|
|
105
|
+
qualifiedId: qualifyWorkbenchRouteId(
|
|
106
|
+
routeModule.packageName || module.packageName,
|
|
107
|
+
routeId,
|
|
108
|
+
),
|
|
109
|
+
defaultPath: route.defaultPath || `/${routeId}`,
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
);
|
|
113
|
+
})
|
|
114
|
+
.sort((left, right) => {
|
|
115
|
+
const leftOrder = left.nav?.order ?? 999;
|
|
116
|
+
const rightOrder = right.nav?.order ?? 999;
|
|
117
|
+
const orderDiff = leftOrder - rightOrder;
|
|
118
|
+
return orderDiff !== 0
|
|
119
|
+
? orderDiff
|
|
120
|
+
: left.title.localeCompare(right.title);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
...module,
|
|
125
|
+
displayName,
|
|
126
|
+
routeModules,
|
|
127
|
+
routes,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function mergeWorkbenchModules(
|
|
132
|
+
modules: SmrtWorkbenchModule[],
|
|
133
|
+
): ResolvedWorkbenchModule[] {
|
|
134
|
+
const byPackage = new Map<string, SmrtWorkbenchModule>();
|
|
135
|
+
|
|
136
|
+
for (const module of modules) {
|
|
137
|
+
const existing = byPackage.get(module.packageName);
|
|
138
|
+
if (!existing) {
|
|
139
|
+
byPackage.set(module.packageName, { ...module });
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
byPackage.set(module.packageName, {
|
|
144
|
+
...existing,
|
|
145
|
+
...module,
|
|
146
|
+
routeModule: undefined,
|
|
147
|
+
routeModules: [
|
|
148
|
+
...(existing.routeModules || []),
|
|
149
|
+
...(existing.routeModule ? [existing.routeModule] : []),
|
|
150
|
+
...(module.routeModules || []),
|
|
151
|
+
...(module.routeModule ? [module.routeModule] : []),
|
|
152
|
+
],
|
|
153
|
+
recommendedCommands: [
|
|
154
|
+
...(existing.recommendedCommands || []),
|
|
155
|
+
...(module.recommendedCommands || []),
|
|
156
|
+
],
|
|
157
|
+
docs: [...(existing.docs || []), ...(module.docs || [])],
|
|
158
|
+
examples: [...(existing.examples || []), ...(module.examples || [])],
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return [...byPackage.values()]
|
|
163
|
+
.map((module) => normalizeWorkbenchModule(module))
|
|
164
|
+
.sort((left, right) => left.displayName.localeCompare(right.displayName));
|
|
165
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import type { Component } from 'svelte';
|
|
2
|
+
|
|
3
|
+
export type WorkbenchComponentType = Component<Record<string, unknown>>;
|
|
4
|
+
export type WorkbenchComponentModule =
|
|
5
|
+
| WorkbenchComponentType
|
|
6
|
+
| {
|
|
7
|
+
default: WorkbenchComponentType;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type WorkbenchComponentLoader = () => Promise<WorkbenchComponentModule>;
|
|
11
|
+
|
|
12
|
+
export type SmrtWorkbenchScopeMode = 'workspace' | 'package' | 'consumer';
|
|
13
|
+
export type SmrtWorkbenchPackageManager = 'pnpm' | 'yarn' | 'npm';
|
|
14
|
+
|
|
15
|
+
export interface SmrtWorkbenchRouteDefinition {
|
|
16
|
+
id: string;
|
|
17
|
+
title: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
defaultPath?: string;
|
|
20
|
+
component?: WorkbenchComponentType;
|
|
21
|
+
loadComponent?: WorkbenchComponentLoader;
|
|
22
|
+
props?: Record<string, unknown>;
|
|
23
|
+
tags?: string[];
|
|
24
|
+
nav?: {
|
|
25
|
+
label?: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
icon?: string;
|
|
28
|
+
order?: number;
|
|
29
|
+
group?: string;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface SmrtWorkbenchRouteModule {
|
|
34
|
+
packageName: string;
|
|
35
|
+
displayName?: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
routes: Record<string, SmrtWorkbenchRouteDefinition>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface SmrtWorkbenchRecommendedCommand {
|
|
41
|
+
id: string;
|
|
42
|
+
label: string;
|
|
43
|
+
command: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface SmrtWorkbenchModule {
|
|
48
|
+
packageName: string;
|
|
49
|
+
displayName?: string;
|
|
50
|
+
description?: string;
|
|
51
|
+
routeModule?: SmrtWorkbenchRouteModule;
|
|
52
|
+
routeModules?: SmrtWorkbenchRouteModule[];
|
|
53
|
+
recommendedCommands?: SmrtWorkbenchRecommendedCommand[];
|
|
54
|
+
docs?: WorkbenchDocumentSummary[];
|
|
55
|
+
examples?: WorkbenchExampleSummary[];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export type SmrtWorkbenchModuleExport =
|
|
59
|
+
| SmrtWorkbenchModule
|
|
60
|
+
| SmrtWorkbenchModule[]
|
|
61
|
+
| {
|
|
62
|
+
modules: SmrtWorkbenchModule[];
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export interface ResolvedWorkbenchRouteEntry
|
|
66
|
+
extends SmrtWorkbenchRouteDefinition {
|
|
67
|
+
packageName: string;
|
|
68
|
+
moduleDisplayName: string;
|
|
69
|
+
routeKey: string;
|
|
70
|
+
qualifiedId: string;
|
|
71
|
+
defaultPath: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface ResolvedWorkbenchModule
|
|
75
|
+
extends Omit<
|
|
76
|
+
SmrtWorkbenchModule,
|
|
77
|
+
'displayName' | 'routeModule' | 'routeModules'
|
|
78
|
+
> {
|
|
79
|
+
displayName: string;
|
|
80
|
+
routeModules: SmrtWorkbenchRouteModule[];
|
|
81
|
+
routes: ResolvedWorkbenchRouteEntry[];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface WorkbenchScopeResolution {
|
|
85
|
+
mode: SmrtWorkbenchScopeMode;
|
|
86
|
+
cwd: string;
|
|
87
|
+
projectRoot: string;
|
|
88
|
+
workspaceRoot?: string;
|
|
89
|
+
packageName?: string;
|
|
90
|
+
packageDir?: string;
|
|
91
|
+
packageManager: SmrtWorkbenchPackageManager;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface WorkbenchDocumentSummary {
|
|
95
|
+
kind: 'readme' | 'agents' | 'changelog' | 'generated' | 'docs' | 'other';
|
|
96
|
+
title: string;
|
|
97
|
+
path: string;
|
|
98
|
+
content?: string;
|
|
99
|
+
truncated?: boolean;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface WorkbenchExampleSummary {
|
|
103
|
+
id: string;
|
|
104
|
+
title: string;
|
|
105
|
+
path?: string;
|
|
106
|
+
language?: string;
|
|
107
|
+
code?: string;
|
|
108
|
+
source: 'file' | 'readme' | 'playground';
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface WorkbenchKnowledgeSummary {
|
|
112
|
+
manifestPath?: string;
|
|
113
|
+
knowledgePath?: string;
|
|
114
|
+
objectCount: number;
|
|
115
|
+
relationshipCount: number;
|
|
116
|
+
promptCount: number;
|
|
117
|
+
mcpToolCount: number;
|
|
118
|
+
surfaceCount: number;
|
|
119
|
+
tags: string[];
|
|
120
|
+
risks: string[];
|
|
121
|
+
objectNames: string[];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface WorkbenchApiObjectFieldSummary {
|
|
125
|
+
name: string;
|
|
126
|
+
type?: string;
|
|
127
|
+
required?: boolean;
|
|
128
|
+
related?: string;
|
|
129
|
+
description?: string;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface WorkbenchApiObjectSummary {
|
|
133
|
+
name: string;
|
|
134
|
+
className?: string;
|
|
135
|
+
qualifiedName?: string;
|
|
136
|
+
collection?: string;
|
|
137
|
+
sourcePath?: string;
|
|
138
|
+
typedocPath?: string;
|
|
139
|
+
description?: string;
|
|
140
|
+
fields: WorkbenchApiObjectFieldSummary[];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export type WorkbenchApiParameterLocation =
|
|
144
|
+
| 'path'
|
|
145
|
+
| 'query'
|
|
146
|
+
| 'body'
|
|
147
|
+
| 'option'
|
|
148
|
+
| 'argument'
|
|
149
|
+
| 'input';
|
|
150
|
+
|
|
151
|
+
export interface WorkbenchApiParameterSummary {
|
|
152
|
+
name: string;
|
|
153
|
+
type?: string;
|
|
154
|
+
required?: boolean;
|
|
155
|
+
location: WorkbenchApiParameterLocation;
|
|
156
|
+
description?: string;
|
|
157
|
+
defaultValue?: string;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface WorkbenchRestEndpointSummary {
|
|
161
|
+
objectName: string;
|
|
162
|
+
action: string;
|
|
163
|
+
method: string;
|
|
164
|
+
path: string;
|
|
165
|
+
description: string;
|
|
166
|
+
parameters: WorkbenchApiParameterSummary[];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export interface WorkbenchCliCommandSummary {
|
|
170
|
+
objectName: string;
|
|
171
|
+
action: string;
|
|
172
|
+
command: string;
|
|
173
|
+
description: string;
|
|
174
|
+
parameters: WorkbenchApiParameterSummary[];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export interface WorkbenchMcpToolSummary {
|
|
178
|
+
objectName: string;
|
|
179
|
+
action: string;
|
|
180
|
+
toolName: string;
|
|
181
|
+
description: string;
|
|
182
|
+
parameters: WorkbenchApiParameterSummary[];
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export interface WorkbenchApiSummary {
|
|
186
|
+
objectNames: string[];
|
|
187
|
+
objects: WorkbenchApiObjectSummary[];
|
|
188
|
+
restEndpoints: WorkbenchRestEndpointSummary[];
|
|
189
|
+
cliCommands: WorkbenchCliCommandSummary[];
|
|
190
|
+
mcpTools: WorkbenchMcpToolSummary[];
|
|
191
|
+
endpointCount: number;
|
|
192
|
+
routeFiles: string[];
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export interface WorkbenchPackageSummary {
|
|
196
|
+
name: string;
|
|
197
|
+
version?: string;
|
|
198
|
+
description?: string;
|
|
199
|
+
source: 'workspace' | 'package' | 'app';
|
|
200
|
+
directory?: string;
|
|
201
|
+
relativeDirectory?: string;
|
|
202
|
+
scripts: Record<string, string>;
|
|
203
|
+
dependencies: Record<string, string>;
|
|
204
|
+
devDependencies: Record<string, string>;
|
|
205
|
+
peerDependencies: Record<string, string>;
|
|
206
|
+
smrtDependencies: string[];
|
|
207
|
+
sdkDependencies: string[];
|
|
208
|
+
exportKeys: string[];
|
|
209
|
+
docs: WorkbenchDocumentSummary[];
|
|
210
|
+
examples: WorkbenchExampleSummary[];
|
|
211
|
+
knowledge: WorkbenchKnowledgeSummary;
|
|
212
|
+
api: WorkbenchApiSummary;
|
|
213
|
+
migrations: string[];
|
|
214
|
+
routeModuleCount: number;
|
|
215
|
+
routeCount: number;
|
|
216
|
+
playgroundEntryCount: number;
|
|
217
|
+
recommendedCommands: SmrtWorkbenchRecommendedCommand[];
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export interface SmrtWorkbenchProject {
|
|
221
|
+
generatedAt: string;
|
|
222
|
+
scope: WorkbenchScopeResolution;
|
|
223
|
+
packages: WorkbenchPackageSummary[];
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface DiscoveredWorkbenchTarget {
|
|
227
|
+
packageName?: string;
|
|
228
|
+
source: 'workspace' | 'package' | 'app';
|
|
229
|
+
sourcePath?: string;
|
|
230
|
+
runtimePath?: string;
|
|
231
|
+
importSpecifier?: string;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export interface SmrtWorkbenchVitePluginOptions {
|
|
235
|
+
mode?: 'auto' | 'workspace' | 'consumer';
|
|
236
|
+
projectRoot?: string;
|
|
237
|
+
workspaceRoot?: string;
|
|
238
|
+
cwd?: string;
|
|
239
|
+
packageName?: string;
|
|
240
|
+
packagesPattern?: string;
|
|
241
|
+
localWorkbenchPath?: string;
|
|
242
|
+
localPlaygroundPath?: string;
|
|
243
|
+
}
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function displayNameForSmrtPackage(packageName: string): string {
|
|
2
|
+
const baseName = packageName
|
|
3
|
+
.replace(/^@happyvertical\/smrt-/, '')
|
|
4
|
+
.replace(/^@happyvertical\/smrt$/, 'SMRT')
|
|
5
|
+
.replace(/^smrt-/, '');
|
|
6
|
+
|
|
7
|
+
return baseName
|
|
8
|
+
.split(/[-_]/g)
|
|
9
|
+
.filter(Boolean)
|
|
10
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
11
|
+
.join(' ');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function commandIdForScript(packageName: string, scriptName: string) {
|
|
15
|
+
return `${packageName}:${scriptName}`;
|
|
16
|
+
}
|