@vivix-labs/studio-workbench 1.0.0-beta.2 → 1.0.0-beta.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/assets/add-circle-RPMXNTWW.svg +4 -0
  2. package/dist/assets/copy-document-EF4PHM7F.svg +10 -0
  3. package/dist/assets/create-custom-view-WUWJL7YC.svg +5 -0
  4. package/dist/assets/crop-5JXWHIPN.svg +6 -0
  5. package/dist/assets/dashboard-overview-Y32BCZQC.svg +8 -0
  6. package/dist/assets/dashboard-views-GOG66UAH.svg +7 -0
  7. package/dist/assets/delete-4Y3OUMEL.svg +8 -0
  8. package/dist/assets/download-VTKCEAZG.svg +6 -0
  9. package/dist/assets/favorite-6GMNHJCN.svg +5 -0
  10. package/dist/assets/favorite-filled-FR74TEBM.svg +3 -0
  11. package/dist/assets/filter-JSDZZVGN.svg +5 -0
  12. package/dist/assets/fullscreen-exit-ADYOPBYH.svg +3 -0
  13. package/dist/assets/inria-serif-latin-400-italic-ZCFRMMVP.woff2 +0 -0
  14. package/dist/assets/inter-latin-900-normal-FKACR3DR.woff2 +0 -0
  15. package/dist/assets/refresh-WQ3CTB57.svg +3 -0
  16. package/dist/assets/replace-PJXDOQDX.svg +3 -0
  17. package/dist/assets/{search-JUOSGQRM.svg → search-FMYQZJWA.svg} +1 -1
  18. package/dist/assets/select-items-GJZIVO37.svg +6 -0
  19. package/dist/assets/trim-LQMHHN2M.svg +9 -0
  20. package/dist/assets/upload-U5RZT5QI.svg +5 -0
  21. package/dist/assets/welcome-add-HS6LIH63.svg +5 -0
  22. package/dist/assets/welcome-close-NOBXBZOT.svg +5 -0
  23. package/dist/assets/welcome-product-ad-YRPDJRAH.png +0 -0
  24. package/dist/assets/welcome-short-drama-YDTZHBGK.png +0 -0
  25. package/dist/client.bundle.js +2731 -1096
  26. package/dist/client.css +1838 -295
  27. package/dist/server.d.ts +1 -0
  28. package/dist/server.js +328 -36
  29. package/dist/shared.d.ts +27 -1
  30. package/dist/shared.js +2 -1
  31. package/package.json +25 -25
  32. package/presets/table.json +4 -4
  33. package/presets/user-base.json +13 -9
  34. package/skills/SKILL.md +20 -39
  35. package/skills/references/assets-and-views.md +6 -6
  36. package/skills/references/sql-custom-views.md +2 -0
  37. package/skills/scripts/initialize-home.mjs +350 -119
  38. package/dist/assets/player-cover-shade-LLH6KOCQ.png +0 -0
@@ -1,37 +1,41 @@
1
1
  import { execFile, spawn } from 'node:child_process';
2
- import { mkdir, readFile, readdir, realpath, rename, rm, writeFile } from 'node:fs/promises';
2
+ import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
3
3
  import { homedir } from 'node:os';
4
- import { basename, dirname, join, resolve, sep } from 'node:path';
5
- import { fileURLToPath } from 'node:url';
6
- import { promisify } from 'node:util';
4
+ import { basename, dirname, join, resolve } from 'node:path';
5
+ import { setTimeout as delay } from 'node:timers/promises';
6
+ import { isDeepStrictEqual, parseArgs, promisify } from 'node:util';
7
7
 
8
8
  const exec = promisify(execFile);
9
- const args = process.argv.slice(2);
10
- if (args.includes('--help')) {
9
+ const { values } = parseArgs({
10
+ options: {
11
+ help: { type: 'boolean' },
12
+ 'no-open': { type: 'boolean' },
13
+ sample: { type: 'string' },
14
+ },
15
+ });
16
+ if (values.help) {
11
17
  console.log(
12
- 'Usage: node initialize-home.mjs [--no-open] [--add-cobalt]\nUse VIVIX_STUDIO_CLI to select a CLI executable or built JS entry.',
18
+ 'Usage: node initialize-home.mjs [--no-open] [--sample out-of-steps|cobalt-headphones]\nUse VIVIX_STUDIO_CLI to select a CLI executable or built JS entry.',
13
19
  );
14
20
  process.exit(0);
15
21
  }
16
- if (args.some((arg) => !['--no-open', '--add-cobalt'].includes(arg)))
17
- throw Error('Unknown option. Use --help.');
18
22
  const executable = process.env.VIVIX_STUDIO_CLI || 'vivix-studio';
19
23
  const js = /\.[cm]?js$/.test(executable);
20
24
  const command = js ? process.execPath : executable;
21
25
  const prefix = js ? [resolve(executable)] : [];
22
- const root = join(process.env.XDG_CONFIG_HOME || join(homedir(), '.config'), 'vivix-studio');
26
+ const root = process.env.XDG_CONFIG_HOME
27
+ ? join(process.env.XDG_CONFIG_HOME, 'vivix-studio')
28
+ : join(homedir(), '.vivix-studio');
23
29
  const userPackage = JSON.parse(
24
30
  await readFile(new URL('../../package.json', import.meta.url), 'utf8'),
25
31
  );
26
32
  const userPreset = `${userPackage.name}@${userPackage.version}:user-base`;
27
- const adsPackage = '@vivix-labs/ads-workbench';
28
- const adsVersion = userPackage.vivixStudio.runtimePlugins[adsPackage];
29
- const adsPreset = `${adsPackage}@${adsVersion}:ads`;
30
- const dramaPreset = '@vivix-labs/short-drama-workbench:short-drama';
31
- const scopes = [
32
- { id: 'out-of-steps', preset: dramaPreset, skill: 'vivix-out-of-steps-example' },
33
- { id: 'cobalt-headphones', preset: adsPreset, skill: 'vivix-cobalt-example' },
34
- ];
33
+ const samples = {
34
+ 'out-of-steps': { package: '@vivix-labs/short-drama-workbench', presetId: 'short-drama' },
35
+ 'cobalt-headphones': { package: '@vivix-labs/ads-workbench', presetId: 'ads' },
36
+ };
37
+ const sample = values.sample;
38
+ if (sample !== undefined && !Object.hasOwn(samples, sample)) throw Error('Unknown sample.');
35
39
  const access =
36
40
  'project.content.read,project.content.write,official.request,events.publish,events.subscribe';
37
41
  const homeState = join(root, 'home-initialization.json');
@@ -43,20 +47,6 @@ const save = async () => {
43
47
  await rename(homeState + '.tmp', homeState);
44
48
  };
45
49
 
46
- async function linkedSeed(project, skill, packageName, version) {
47
- const links = join(project.root, '.agents', 'skills');
48
- const pluginRoot = await realpath(join(root, 'plugins'));
49
- for (const entry of await readdir(links, { withFileTypes: true })) {
50
- if (!entry.isSymbolicLink()) continue;
51
- const target = await realpath(join(links, entry.name)).catch(() => null);
52
- if (!target?.startsWith(pluginRoot + sep) || basename(target) !== skill) continue;
53
- const pkg = await read(join(target, '..', '..', 'package.json'));
54
- if (pkg.name === packageName && pkg.version === version)
55
- return join(target, 'scripts', 'initialize.mjs');
56
- }
57
- throw Error('Cannot find the installed seed Skill: ' + skill);
58
- }
59
-
60
50
  async function cli(...arguments_) {
61
51
  let stdout;
62
52
  try {
@@ -79,12 +69,19 @@ function interrupt(signal) {
79
69
  }
80
70
  function runSeed(path, project) {
81
71
  return new Promise((done, reject) => {
82
- child = spawn(process.execPath, [path, '--project', project, '--apply'], { stdio: 'inherit' });
72
+ child = spawn(process.execPath, [path, '--project', project, '--apply'], {
73
+ stdio: ['ignore', 'ignore', 'pipe'],
74
+ });
75
+ let failure = '';
76
+ child.stderr.setEncoding('utf8').on('data', (chunk) => {
77
+ failure = (failure + chunk).slice(-4096);
78
+ });
83
79
  child.on('error', reject);
84
80
  child.on('close', (code) => {
85
81
  child = undefined;
86
82
  if (code === 0) done();
87
- else reject(Error('Example import stopped. Rerun initialization to resume.'));
83
+ else
84
+ reject(Error(failure.trim() || 'Example import stopped. Rerun initialization to resume.'));
88
85
  });
89
86
  });
90
87
  }
@@ -92,6 +89,243 @@ function assertRunning() {
92
89
  if (stopped) throw Error('Initialization stopped. Rerun it to resume.');
93
90
  }
94
91
 
92
+ async function warmDramaWorkbenches() {
93
+ const { stdout } = await exec(command, [...prefix, 'preset', '--help']);
94
+ if (!stdout.includes('warm-client')) return;
95
+ const name = samples['out-of-steps'].package;
96
+ const version = userPackage.vivixStudio.runtimePlugins[name];
97
+ for (const id of ['out-of-steps', 'short-drama'])
98
+ await cli('preset', 'warm-client', `${name}@${version}:${id}`);
99
+ }
100
+
101
+ function sameSet(actual = [], expected = []) {
102
+ const a = new Set(actual);
103
+ const b = new Set(expected);
104
+ return a.size === b.size && [...a].every((item) => b.has(item));
105
+ }
106
+
107
+ function legacyPackageName(name) {
108
+ return name.startsWith('@vivix-labs/') ? '@vivix/' + name.slice('@vivix-labs/'.length) : name;
109
+ }
110
+
111
+ function planUserBaseUpdate(userBase, snapshot, globalPackages, userInstances) {
112
+ const composition = structuredClone(snapshot.composition);
113
+ const lock = structuredClone(snapshot.lock);
114
+ const existingById = new Map(composition.plugins.map((item) => [item.id, item]));
115
+ const runningById = new Map(userInstances.map((item) => [item.id, item]));
116
+ const installedByKey = new Map(
117
+ globalPackages.map((item) => [`${item.package}@${item.version}`, item]),
118
+ );
119
+ const managedIds = new Set(userBase.plugins.map((item) => item.id));
120
+ let changed = false;
121
+ const managedPlugins = [];
122
+ const verifiedTargets = [];
123
+
124
+ for (const target of userBase.plugins) {
125
+ const existing = existingById.get(target.id);
126
+ const previousLock = lock.instances[target.id];
127
+ // Preserve intentionally disabled plugins and existing `data` providers managed by upgrade-data.mjs.
128
+ if (existing && (existing.enabled === false || (target.id === 'data' && previousLock))) {
129
+ managedPlugins.push(existing);
130
+ continue;
131
+ }
132
+ const installed = installedByKey.get(`${target.package}@${target.version}`);
133
+ if (!installed?.integrity)
134
+ throw Error(`Required Studio plugin is not installed: ${target.package}@${target.version}.`);
135
+ if (
136
+ existing &&
137
+ existing.package !== target.package &&
138
+ existing.package !== legacyPackageName(target.package)
139
+ )
140
+ throw Error(
141
+ `Cannot upgrade Studio workspace: instance "${target.id}" belongs to ${existing.package}.`,
142
+ );
143
+ const access = [
144
+ ...new Set([...(previousLock?.access ?? []), ...(target.requiredAccess ?? [])]),
145
+ ];
146
+ const running = runningById.get(target.id);
147
+ if (
148
+ !existing ||
149
+ existing.package !== target.package ||
150
+ existing.enabled !== target.enabled ||
151
+ !isDeepStrictEqual(existing.config, target.config) ||
152
+ previousLock?.package !== target.package ||
153
+ previousLock?.version !== target.version ||
154
+ previousLock?.integrity !== installed.integrity ||
155
+ !sameSet(previousLock?.access, access) ||
156
+ running?.state !== 'ready'
157
+ )
158
+ changed = true;
159
+
160
+ managedPlugins.push({
161
+ id: target.id,
162
+ package: target.package,
163
+ enabled: target.enabled,
164
+ config: structuredClone(target.config),
165
+ });
166
+ verifiedTargets.push(target);
167
+ lock.instances[target.id] = {
168
+ package: target.package,
169
+ version: target.version,
170
+ integrity: installed.integrity,
171
+ access,
172
+ };
173
+ }
174
+
175
+ composition.plugins = [
176
+ ...managedPlugins,
177
+ ...composition.plugins.filter((item) => !managedIds.has(item.id)),
178
+ ];
179
+ const expectedBasedOn = {
180
+ package: userPackage.name,
181
+ version: userPackage.version,
182
+ presetId: userBase.id,
183
+ };
184
+ if (!isDeepStrictEqual(composition.basedOn, expectedBasedOn)) {
185
+ composition.basedOn = expectedBasedOn;
186
+ changed = true;
187
+ }
188
+ if (!composition.workspace && userBase.workspace) {
189
+ composition.workspace = structuredClone(userBase.workspace);
190
+ changed = true;
191
+ } else if (
192
+ userBase.workspace?.frontend &&
193
+ !isDeepStrictEqual(composition.workspace?.frontend, userBase.workspace.frontend)
194
+ ) {
195
+ composition.workspace = {
196
+ ...composition.workspace,
197
+ frontend: structuredClone(userBase.workspace.frontend),
198
+ settings: composition.workspace?.settings ?? {},
199
+ };
200
+ changed = true;
201
+ }
202
+ return { changed, composition, lock, verifiedTargets };
203
+ }
204
+
205
+ async function confirmRunningHost() {
206
+ const host = await read(join(root, 'runtime/host.json'));
207
+ const origin = new URL(host.origin);
208
+ if (
209
+ origin.protocol !== 'http:' ||
210
+ origin.hostname !== '127.0.0.1' ||
211
+ origin.pathname !== '/' ||
212
+ origin.username ||
213
+ origin.password ||
214
+ origin.search ||
215
+ origin.hash ||
216
+ typeof host.token !== 'string' ||
217
+ host.token.length < 20 ||
218
+ host.pid !== (await cli('host', 'status')).pid
219
+ )
220
+ throw Error('Cannot confirm the running Studio Host.');
221
+ return host;
222
+ }
223
+
224
+ async function postUserConfiguration(composition, lock, expectedRevision) {
225
+ const host = await confirmRunningHost();
226
+ const response = await fetch(host.origin + '/v1/user/configure', {
227
+ method: 'POST',
228
+ headers: { Authorization: 'Bearer ' + host.token, 'Content-Type': 'application/json' },
229
+ body: JSON.stringify({ composition, lock, expectedRevision }),
230
+ redirect: 'error',
231
+ signal: AbortSignal.timeout(300000),
232
+ });
233
+ const reply = await response.json();
234
+ if (!response.ok || !reply.ok)
235
+ throw Object.assign(Error(reply.error?.message || 'Workspace upgrade failed.'), {
236
+ code: reply.error?.code,
237
+ });
238
+ }
239
+
240
+ async function reconcileUserBase() {
241
+ const userBase = await read(new URL('../../presets/user-base.json', import.meta.url));
242
+ const [user, snapshot, globalReply] = await Promise.all([
243
+ cli('plugin', 'list', '--scope', 'user'),
244
+ cli('project', 'inspect', '--scope', 'user'),
245
+ cli('plugin', 'list', '--global'),
246
+ ]);
247
+ const plan = planUserBaseUpdate(userBase, snapshot, globalReply.packages, user.instances);
248
+ if (!plan.changed) return;
249
+
250
+ try {
251
+ await postUserConfiguration(plan.composition, plan.lock, snapshot.composition.revision);
252
+ } catch (error) {
253
+ if (error.code !== 'USER_SCOPE_IN_USE') throw error;
254
+ await cli('host', 'stop');
255
+ for (let i = 0; (await cli('host', 'status')).pid; i++) {
256
+ if (i === 60)
257
+ throw Error('Studio Host is still stopping. Rerun initialization after it exits.');
258
+ await delay(500);
259
+ }
260
+ await cli('plugin', 'list', '--scope', 'user');
261
+ await postUserConfiguration(plan.composition, plan.lock, snapshot.composition.revision);
262
+ }
263
+
264
+ const after = await cli('plugin', 'list', '--scope', 'user');
265
+ for (const target of plan.verifiedTargets) {
266
+ const current = after.instances.find((item) => item.id === target.id);
267
+ if (
268
+ !current ||
269
+ current.state !== 'ready' ||
270
+ current.package !== target.package ||
271
+ current.version !== target.version
272
+ )
273
+ throw Error(
274
+ `Studio user plugin ${target.id} did not become ready: ${current?.reason || 'missing'}`,
275
+ );
276
+ }
277
+ }
278
+
279
+ async function configureDramaChat(projectId) {
280
+ // Trial setup can enable chat before the on-demand drama project exists.
281
+ const user = await cli('plugin', 'list', '--scope', 'user');
282
+ const chat = user.instances.find(
283
+ (item) =>
284
+ item.id === 'chat-components' &&
285
+ item.package === '@vivix-labs/chat-components' &&
286
+ item.state === 'ready',
287
+ );
288
+ if (!chat) return;
289
+ const project = await cli('plugin', 'list', '--project', projectId);
290
+ const current = project.instances.find((item) => item.id === chat.id);
291
+ if (current && current.package !== chat.package)
292
+ throw Error('Another plugin owns the chat-components instance.');
293
+ if (current?.config.libraryInstance) return;
294
+ const libraries = user.instances.filter(
295
+ (item) =>
296
+ item.package === '@vivix-labs/material-library' &&
297
+ item.state === 'ready' &&
298
+ item.config.role === 'service',
299
+ );
300
+ if (libraries.length !== 1)
301
+ throw Error('Configure one ready user material library before enabling chat file uploads.');
302
+ const config = join(lock, 'chat-components.json');
303
+ await writeFile(
304
+ config,
305
+ JSON.stringify({
306
+ ...(current?.config || {
307
+ targets: { character: { instanceId: 'authoring', operationId: 'characters.receiveCard' } },
308
+ }),
309
+ libraryInstance: `user:${libraries[0].id}`,
310
+ }),
311
+ { mode: 0o600 },
312
+ );
313
+ await cli(
314
+ 'plugin',
315
+ 'enable',
316
+ chat.package,
317
+ '--version',
318
+ current?.version ?? chat.version,
319
+ '--project',
320
+ projectId,
321
+ '--instance',
322
+ chat.id,
323
+ '--config',
324
+ config,
325
+ '--trust',
326
+ );
327
+ }
328
+
95
329
  await mkdir(dirname(homeState), { recursive: true, mode: 0o700 });
96
330
  try {
97
331
  await mkdir(lock, { mode: 0o700 });
@@ -112,79 +346,79 @@ try {
112
346
  } catch (error) {
113
347
  if (error.code !== 'ENOENT') throw error;
114
348
  }
115
- const addingCobalt = args.includes('--add-cobalt');
116
- if (!state.complete || (addingCobalt && !state.projects['cobalt-headphones']?.complete)) {
117
- // Resume an older unfinished Home using its original project identities.
118
- const requested =
119
- state.projects['rhode-summer-launch'] && !state.complete && !addingCobalt
120
- ? [
121
- scopes[0],
122
- { id: 'rhode-summer-launch', preset: adsPreset, skill: 'vivix-rhode-example' },
123
- ]
124
- : scopes;
125
- const { presets } = await cli('preset', 'list');
126
- const dramaPackage = '@vivix-labs/short-drama-workbench';
127
- const drama = presets.find(
128
- (item) =>
129
- item.package === dramaPackage &&
130
- item.version === userPackage.vivixStudio.runtimePlugins[dramaPackage] &&
131
- item.presetId === 'short-drama',
132
- );
133
- if (
134
- !drama ||
135
- !presets.some(
136
- (item) =>
137
- item.package === adsPackage && item.version === adsVersion && item.presetId === 'ads',
138
- ) ||
139
- !['user-base'].every((presetId) =>
140
- presets.some(
141
- (item) =>
142
- item.package === userPackage.name &&
143
- item.version === userPackage.version &&
144
- item.presetId === presetId,
145
- ),
146
- )
147
- )
148
- throw Error(
149
- 'Install the matching Home, Short Drama and Advertising preset packages before initializing Home.',
349
+ if (!state.workspace) {
350
+ const user = await cli('plugin', 'list', '--scope', 'user');
351
+ if (user.instances.length) {
352
+ const installed = user.instances.find((item) => item.id === 'workbench');
353
+ if (installed?.package !== userPackage.name || installed.version !== userPackage.version)
354
+ throw Error(
355
+ 'This profile already has a different user workbench. Use a fresh profile for first setup.',
356
+ );
357
+ } else {
358
+ await cli(
359
+ 'preset',
360
+ 'apply',
361
+ userPreset,
362
+ '--scope',
363
+ 'user',
364
+ '--trust',
365
+ '--allow-access',
366
+ access,
150
367
  );
151
- if (!state.workspace) {
152
- const user = await cli('plugin', 'list', '--scope', 'user');
153
- if (user.instances.length) {
154
- const installed = user.instances.find((item) => item.id === 'workbench');
155
- if (installed?.package !== userPackage.name || installed.version !== userPackage.version)
156
- throw Error(
157
- 'This profile already has a different user workbench. Use a fresh profile for first setup.',
158
- );
159
- } else {
160
- await cli(
161
- 'preset',
162
- 'apply',
163
- userPreset,
164
- '--scope',
165
- 'user',
166
- '--trust',
167
- '--allow-access',
168
- access,
368
+ }
369
+ state.workspace = true;
370
+ await save();
371
+ } else if (!sample) {
372
+ await reconcileUserBase();
373
+ }
374
+ if (sample) {
375
+ assertRunning();
376
+ const directory = join(root, 'projects', 'studio-home-examples', sample);
377
+ const { projects } = await cli('project', 'list');
378
+ let receipt = state.projects[sample];
379
+ if (!receipt && sample === 'out-of-steps') {
380
+ // Match the browser creation receipt, so CLI and Welcome share the prepared project.
381
+ const requestId = '66067767-ff7a-4c73-9cd2-debde07b6ea2';
382
+ for (const project of projects) {
383
+ if (!project.available || basename(project.root) !== `project-${requestId}`) continue;
384
+ const created = await read(join(project.root, '.vivix/workbench-create.json')).catch(
385
+ (error) => {
386
+ if (error.code !== 'ENOENT') throw error;
387
+ return undefined;
388
+ },
169
389
  );
390
+ if (created?.requestId !== requestId || !created.preset.endsWith(':out-of-steps')) continue;
391
+ await read(join(project.root, '.vivix/out-of-steps.initialized.json'));
392
+ receipt = state.projects[sample] = {
393
+ directory: project.root,
394
+ preset: created.preset,
395
+ projectId: project.id,
396
+ complete: true,
397
+ };
398
+ await save();
170
399
  }
171
- state.workspace = true;
172
- await save();
173
400
  }
174
- for (const spec of requested) {
175
- assertRunning();
176
- const preset =
177
- spec.preset === dramaPreset ? `${drama.package}@${drama.version}:short-drama` : spec.preset;
178
- let receipt = state.projects[spec.id];
179
- const directory = join(root, 'projects', 'studio-home-examples', spec.id);
180
- const { projects } = await cli('project', 'list');
401
+ if (!receipt?.complete) {
402
+ const spec = samples[sample];
403
+ const samplePreset = `${spec.package}@${userPackage.vivixStudio.runtimePlugins[spec.package]}:${spec.presetId}`;
404
+ const { presets } = await cli('preset', 'list');
405
+ const preparedPreset = samplePreset.replace(/:short-drama$/, ':out-of-steps');
406
+ const hasPrepared =
407
+ sample === 'out-of-steps' &&
408
+ presets.some(
409
+ (item) => `${item.package}@${item.version}:${item.presetId}` === preparedPreset,
410
+ );
411
+ const preset = receipt?.preset ?? (hasPrepared ? preparedPreset : samplePreset);
412
+ const installed = presets.find(
413
+ (item) => `${item.package}@${item.version}:${item.presetId}` === samplePreset,
414
+ );
415
+ if (!installed) throw Error('Install the matching workbench plugin to load this sample.');
181
416
  if (!receipt) {
182
417
  if (projects.some((item) => item.root === directory))
183
418
  throw Error('The example directory is already registered: ' + directory);
184
- receipt = state.projects[spec.id] = { directory, preset };
419
+ receipt = state.projects[sample] = { directory, preset };
185
420
  await save();
186
421
  }
187
- if (receipt.complete) continue;
188
422
  if (!receipt.projectId) {
189
423
  const registered = projects.find(
190
424
  (item) => item.root === receipt.directory && item.available,
@@ -194,7 +428,7 @@ try {
194
428
  (await cli(
195
429
  'project',
196
430
  'init',
197
- spec.id,
431
+ sample,
198
432
  '--directory',
199
433
  receipt.directory,
200
434
  '--preset',
@@ -207,32 +441,29 @@ try {
207
441
  await save();
208
442
  }
209
443
  assertRunning();
210
- const project = (await cli('project', 'list')).projects.find(
211
- (item) => item.id === receipt.projectId && item.available,
212
- );
213
- if (!project) throw Error('The example project is unavailable: ' + receipt.projectId);
214
- await cli('project', 'open', '--project', project.id, '--no-open');
215
- const seed =
216
- spec.preset === adsPreset
217
- ? await linkedSeed(project, spec.skill, adsPackage, adsVersion)
218
- : await linkedSeed(
219
- project,
220
- spec.skill,
221
- drama.package,
222
- receipt.preset.split('@').at(-1).split(':')[0],
223
- );
224
- await runSeed(seed, project.id);
444
+ if (receipt.preset.endsWith(':out-of-steps')) {
445
+ await read(join(receipt.directory, '.vivix/out-of-steps.initialized.json'));
446
+ } else {
447
+ await runSeed(
448
+ join(installed.packageRoot, 'samples', sample, 'scripts/initialize.mjs'),
449
+ receipt.projectId,
450
+ );
451
+ if (sample === 'out-of-steps') await configureDramaChat(receipt.projectId);
452
+ }
225
453
  receipt.complete = true;
226
454
  await save();
227
455
  }
228
- state.complete = true;
229
- await save();
230
- }
231
- assertRunning();
232
- if (args.includes('--no-open')) {
456
+ const project = (await cli('project', 'list')).projects.find(
457
+ (item) => item.id === receipt.projectId && item.available,
458
+ );
459
+ if (!project) throw Error('The sample project is unavailable: ' + receipt.projectId);
460
+ console.log(JSON.stringify({ ok: true, project }));
461
+ } else if (values['no-open']) {
462
+ await warmDramaWorkbenches();
233
463
  const { workbenchUrl } = await cli('project', 'open', '--scope', 'user', '--no-open');
234
464
  console.log(JSON.stringify({ ok: true, projects: state.projects, workbenchUrl }));
235
465
  } else {
466
+ await warmDramaWorkbenches();
236
467
  await exec(command, [...prefix, 'project', 'open', '--scope', 'user']);
237
468
  }
238
469
  } catch (error) {