cladogram 0.5.5-beta.8 → 0.6.0-beta.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.
@@ -24,7 +24,7 @@ const registryEntrySchema = z.strictObject({
24
24
  icon: z.string().max(16).optional(),
25
25
  readme: z.string().max(4000).optional(),
26
26
  author: z.string().max(80).default('community'),
27
- engines: z.strictObject({ clado: z.string().min(1).max(120) }).default({ clado: '^0.5.4' }),
27
+ engines: z.strictObject({ clado: z.string().min(1).max(120) }).default({ clado: '>=0.5.4 <1.0.0' }),
28
28
  permissions: z.array(z.string().max(120)).max(64).default([]),
29
29
  homepage: z.string().max(512).optional(),
30
30
  sourceDir: z.string().max(512).optional(),
@@ -83,7 +83,7 @@ export function scaffoldPlugin({ dir, id, name, kind = 'ui' }) {
83
83
  if (existsSync(targetDir)) fail(`目标目录已存在:${targetDir}`, 409);
84
84
 
85
85
  const displayName = (name || id.split('.').pop()).trim();
86
- const baseRange = '^0.5.4';
86
+ const baseRange = '>=0.5.4 <1.0.0';
87
87
  const manifest = {
88
88
  manifestVersion: 1,
89
89
  id,
@@ -295,7 +295,7 @@ const DEFAULT_REGISTRY = {
295
295
  readme: '数据以结构化 JSON 持久化于子工作区 `.clado/objects/`,长按画布空白或卡片即可贴便签,长按便签可选中并发给当前 Agent 会话。',
296
296
  category: 'ui',
297
297
  author: 'Clado Labs',
298
- engines: { clado: '^0.5.4' },
298
+ engines: { clado: '>=0.5.4 <1.0.0' },
299
299
  permissions: ['ui.mount:sidebar', 'canvas.document.read', 'canvas.selection.read'],
300
300
  },
301
301
  {
@@ -309,7 +309,7 @@ const DEFAULT_REGISTRY = {
309
309
  readme: '只读访问当前打开画布标题与选中节点数量,并注册 `inspect.summary` 能力供 Agent 调用。',
310
310
  category: 'ui',
311
311
  author: 'Clado',
312
- engines: { clado: '^0.5.4' },
312
+ engines: { clado: '>=0.5.4 <1.0.0' },
313
313
  permissions: ['ui.mount:sidebar', 'canvas.document.read', 'canvas.selection.read'],
314
314
  },
315
315
  {
@@ -323,7 +323,7 @@ const DEFAULT_REGISTRY = {
323
323
  readme: '演示多实例容器与内部 `data-subtarget` 子区域靶点的双级上下文菜单及自绘音波选中态。',
324
324
  category: 'ui',
325
325
  author: 'Community',
326
- engines: { clado: '^0.5.4' },
326
+ engines: { clado: '>=0.5.4 <1.0.0' },
327
327
  permissions: ['ui.mount:sidebar', 'canvas.selection.read'],
328
328
  },
329
329
  {
@@ -337,7 +337,7 @@ const DEFAULT_REGISTRY = {
337
337
  readme: '高敏执行器级插件,安装前自动展示进程调用权限审计清单,支持在会话详情「派发开发」中直接调用。',
338
338
  category: 'executor',
339
339
  author: 'Clado',
340
- engines: { clado: '^0.5.4' },
340
+ engines: { clado: '>=0.5.4 <1.0.0' },
341
341
  permissions: ['ui.mount:sidebar', 'canvas.document.read'],
342
342
  },
343
343
  ],
@@ -350,7 +350,7 @@ export function buildCatalogPluginFiles(entry) {
350
350
  id: entry.id,
351
351
  name: entry.name,
352
352
  version: entry.version || '0.1.0',
353
- engines: entry.engines || { clado: '^0.5.4' },
353
+ engines: entry.engines || { clado: '>=0.5.4 <1.0.0' },
354
354
  protocols: ['1.0'],
355
355
  entrypoints: { ui: { path: 'ui/index.html' } },
356
356
  permissions: entry.permissions?.length ? entry.permissions : ['ui.mount:sidebar', 'canvas.document.read'],
@@ -8,8 +8,8 @@ import { DocumentError } from '../workspace/documents.js';
8
8
  import { capabilityDefinition, capabilityPermission, compileCapabilities, mountId, pluginId } from './plugin-capabilities.js';
9
9
  import { captureDefinition } from './canvas-capture.js';
10
10
  import { compileConfiguration, pluginConfiguration } from './plugin-settings.js';
11
- import { executorSchema } from '../agent/executors.js';
12
11
  import { locked, fail } from '../workspace/storage.js';
12
+ const executorSchema = z.object({ id: z.string().min(1), name: z.string().min(1) }).passthrough();
13
13
 
14
14
  export const PLUGIN_PROTOCOL = '1.0';
15
15
  export const PLUGIN_SLOTS = ['topbar', 'bottombar', 'sidebar', 'bottom-left', 'canvas-overlay', 'top-left', 'top-right', 'bottom-right'];
@@ -23,6 +23,22 @@ const permission = z.enum([
23
23
  ...PLUGIN_SLOTS.map(slot => 'ui.mount:' + slot),
24
24
  ...PLUGIN_FIELDS.map(field => 'canvas.' + field + '.read'),
25
25
  ]);
26
+ const pluginMcpEntry = z.strictObject({
27
+ name: z.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,47}$/),
28
+ type: z.enum(['stdio', 'http', 'streamable-http']).optional(),
29
+ command: z.string().trim().min(1).max(200).optional(),
30
+ args: z.array(z.string().max(200)).max(32).optional(),
31
+ env: z.record(z.string(), z.string()).optional(),
32
+ url: z.string().trim().min(1).max(400).optional(),
33
+ headers: z.record(z.string(), z.string()).optional(),
34
+ enabled: z.boolean().optional(),
35
+ });
36
+ const pluginPersonaEntry = z.strictObject({
37
+ id: z.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,31}$/),
38
+ name: z.string().trim().min(1).max(40),
39
+ prompt: z.string().max(4000).default(''),
40
+ initContext: z.string().max(2000).default(''),
41
+ });
26
42
  const manifest = z.strictObject({
27
43
  manifestVersion: z.literal(1),
28
44
  id: pluginId,
@@ -33,15 +49,19 @@ const manifest = z.strictObject({
33
49
  }, '需要有效 SemVer'),
34
50
  engines: z.strictObject({ clado: z.string().min(1).max(200) }),
35
51
  protocols: z.array(z.string().regex(/^\d+\.\d+$/)).min(1).max(16),
36
- entrypoints: z.strictObject({ ui: z.strictObject({ path: z.string().max(240).regex(uiPath) }) }),
52
+ entrypoints: z.strictObject({ ui: z.strictObject({ path: z.string().max(240).regex(uiPath) }).optional() }).optional(),
37
53
  permissions: z.array(z.union([permission, capabilityPermission])).max(64).default([]),
38
54
  configuration: pluginConfiguration.optional(),
39
55
  contributes: z.strictObject({
40
56
  mounts: z.array(z.strictObject({
41
57
  id: mountId, slot: z.enum(PLUGIN_SLOTS),
42
- })).min(1).max(8),
58
+ })).max(8).default([]),
43
59
  capabilities: z.array(capabilityDefinition).max(16).default([]),
44
60
  executors: z.array(executorSchema).max(8).default([]),
61
+ mcp: z.array(pluginMcpEntry).max(16).default([]),
62
+ personas: z.array(pluginPersonaEntry).max(12).default([]),
63
+ skills: z.boolean().optional(),
64
+ commands: z.boolean().optional(),
45
65
  events: z.tuple([]).optional(),
46
66
  }),
47
67
  });
@@ -110,12 +130,27 @@ function readManifest(root) {
110
130
  throw new Error(`插件需要 Clado ${data.engines.clado},当前版本为 ${VERSION}。`);
111
131
  }
112
132
  if (!data.protocols.includes(PLUGIN_PROTOCOL)) throw new Error(`插件需要声明协议 ${PLUGIN_PROTOCOL}。`);
113
- const mounts = data.contributes.mounts;
133
+ const mounts = data.contributes.mounts || [];
114
134
  if (new Set(mounts.map(mount => mount.id)).size !== mounts.length) throw new Error('挂载 ID 重复。');
115
135
  for (const { slot } of mounts) {
116
136
  if (!data.permissions.includes('ui.mount:' + slot)) throw new Error(`缺少挂载权限 ui.mount:${slot}。`);
117
137
  }
118
- readPackageFile(root, data.entrypoints.ui.path.split('/'), 2 * 1024 * 1024);
138
+ const hasUi = Boolean(data.entrypoints?.ui?.path);
139
+ const hasAgentBundle = Boolean(
140
+ data.contributes.executors?.length
141
+ || data.contributes.mcp?.length
142
+ || data.contributes.personas?.length
143
+ || data.contributes.skills
144
+ || data.contributes.commands
145
+ || existsSync(join(root, 'skills'))
146
+ || existsSync(join(root, 'commands'))
147
+ );
148
+ if (hasUi) {
149
+ if (!mounts.length) throw new Error('声明了 UI 入口的插件至少需要一个挂载点(contributes.mounts)。');
150
+ readPackageFile(root, data.entrypoints.ui.path.split('/'), 2 * 1024 * 1024);
151
+ } else if (!hasAgentBundle) {
152
+ throw new Error('插件需要提供 UI 入口或至少声明一项能力(skills / commands / mcp / personas / executors)。');
153
+ }
119
154
  return { data, capabilities: compileCapabilities(data.id, mounts, data.contributes.capabilities),
120
155
  configuration: compileConfiguration(data.configuration) };
121
156
  }
@@ -127,8 +162,13 @@ export function installWorkspacePlugin(ctx, files, runtime) {
127
162
  for (const file of files) {
128
163
  if (typeof file?.path !== 'string' || typeof file.data !== 'string' || file.path.length > 240) fail('插件文件参数无效。');
129
164
  const parts = file.path.split('/');
130
- if (!parts.every(part => segment.test(part)) ||
131
- (file.path !== 'clado-plugin.json' && (parts[0] !== 'ui' || !contentTypes.has(extname(file.path).toLowerCase())))) fail('插件包仅接受清单和 ui 目录中的资源。');
165
+ const ext = extname(file.path).toLowerCase();
166
+ const isManifest = file.path === 'clado-plugin.json';
167
+ const isUiAsset = parts[0] === 'ui' && contentTypes.has(ext);
168
+ const isBundleDoc = (parts[0] === 'skills' || parts[0] === 'commands') && (ext === '.md' || ext === '.json' || ext === '.txt');
169
+ if (!parts.every(part => segment.test(part)) || (!isManifest && !isUiAsset && !isBundleDoc)) {
170
+ fail('插件包仅接受清单、ui 静态资源以及 skills / commands 文本文件。');
171
+ }
132
172
  if (parsed.has(file.path)) fail('插件包中有重复的文件路径。');
133
173
  const data = Buffer.from(file.data, 'base64');
134
174
  if (data.toString('base64') !== file.data) fail('插件文件编码无效。');
@@ -178,16 +218,28 @@ export function loadWorkspacePlugins(state) {
178
218
  if (error.code !== 'ENOENT') warnings.push({ directory: '.clado/plugins', message: error.message });
179
219
  }
180
220
  const candidates = new Map();
221
+ const pluginDirs = [];
222
+ const pluginMcp = [];
223
+ const pluginPersonas = [];
181
224
  function register(root, { data, capabilities: declared, configuration }) {
182
225
  configurations.set(data.id, configuration);
183
226
  capabilities.push(...declared);
227
+ pluginDirs.push({ id: data.id, dir: root });
228
+ for (const m of data.contributes.mcp || []) {
229
+ pluginMcp.push({ ...m, pluginId: data.id });
230
+ }
231
+ for (const p of data.contributes.personas || []) {
232
+ pluginPersonas.push({ ...p, pluginId: data.id });
233
+ }
184
234
  const key = randomUUID();
185
235
  packages.set(key, root);
186
236
  plugins.push({
187
237
  id: data.id, name: data.name, version: data.version,
188
- entry: ASSETS + key + '/' + data.entrypoints.ui.path,
189
- permissions: data.permissions, mounts: data.contributes.mounts, capabilities: declared.map(item => item.descriptor),
238
+ ...(data.entrypoints?.ui?.path ? { entry: ASSETS + key + '/' + data.entrypoints.ui.path } : {}),
239
+ permissions: data.permissions, mounts: data.contributes.mounts || [], capabilities: declared.map(item => item.descriptor),
190
240
  ...(data.contributes.executors?.length ? { executors: data.contributes.executors } : {}),
241
+ ...(data.contributes.mcp?.length ? { mcp: data.contributes.mcp.map(m => m.name) } : {}),
242
+ ...(data.contributes.personas?.length ? { personas: data.contributes.personas.map(p => p.id) } : {}),
191
243
  });
192
244
  }
193
245
  for (const entry of entries) {
@@ -232,7 +284,7 @@ export function loadWorkspacePlugins(state) {
232
284
  });
233
285
  res.end(req.method === 'HEAD' ? undefined : body);
234
286
  }
235
- return { descriptor, warnings, serveAsset, hasAsset: key => packages.has(key), capabilities, configurations, register };
287
+ return { descriptor, warnings, serveAsset, hasAsset: key => packages.has(key), capabilities, configurations, register, pluginDirs, pluginMcp, pluginPersonas };
236
288
  }
237
289
 
238
290
  export function inspectWorkspacePlugins(state) {
@@ -5,7 +5,7 @@
5
5
  * - 浏览器端一键新建初始画布文档(告别“必须先用外部客户端建文档”的死胡同)
6
6
  */
7
7
 
8
- import { existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
8
+ import { existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
9
9
  import { homedir } from 'node:os';
10
10
  import { basename, dirname, join, resolve } from 'node:path';
11
11
  import { DocumentError, scanDirectory, workspacePath } from '../workspace/documents.js';
@@ -32,6 +32,52 @@ function countMarkdownInWorkspace(wsDir) {
32
32
  }
33
33
  }
34
34
 
35
+ const CODE_EXT_LANG = {
36
+ ts: 'TypeScript', tsx: 'TypeScript', js: 'JavaScript', jsx: 'JavaScript', mjs: 'JavaScript',
37
+ py: 'Python', go: 'Go', rs: 'Rust', java: 'Java', kt: 'Kotlin', rb: 'Ruby', php: 'PHP', vue: 'Vue', svelte: 'Svelte',
38
+ };
39
+
40
+ export function detectWorkspaceProfile(wsDir) {
41
+ let gitBranch = '';
42
+ try {
43
+ const headFile = join(wsDir, '.git', 'HEAD');
44
+ if (existsSync(headFile)) {
45
+ const text = readFileSync(headFile, 'utf8').trim();
46
+ const m = text.match(/^ref:\s*refs\/heads\/(.+)$/);
47
+ gitBranch = m ? m[1] : text.slice(0, 7);
48
+ }
49
+ } catch {}
50
+
51
+ let codeFiles = 0;
52
+ const langCounts = new Map();
53
+ const walk = (dir, depth) => {
54
+ if (depth > 3 || codeFiles >= 300) return;
55
+ let items = [];
56
+ try { items = readdirSync(dir, { withFileTypes: true }); } catch { return; }
57
+ for (const item of items) {
58
+ if (item.name.startsWith('.') || item.name === 'node_modules' || item.name === 'dist' || item.name === 'build' || item.name === 'vendor' || item.name === 'target') continue;
59
+ const full = join(dir, item.name);
60
+ if (item.isDirectory()) {
61
+ walk(full, depth + 1);
62
+ } else if (item.isFile()) {
63
+ const ext = item.name.split('.').pop()?.toLowerCase() || '';
64
+ const lang = CODE_EXT_LANG[ext];
65
+ if (lang) {
66
+ codeFiles++;
67
+ langCounts.set(lang, (langCounts.get(lang) || 0) + 1);
68
+ }
69
+ }
70
+ }
71
+ };
72
+ try { walk(wsDir, 0); } catch {}
73
+ let primaryLang = '';
74
+ let maxCount = 0;
75
+ for (const [lang, cnt] of langCounts) {
76
+ if (cnt > maxCount) { maxCount = cnt; primaryLang = lang; }
77
+ }
78
+ return { gitBranch, codeFiles, primaryLang };
79
+ }
80
+
35
81
  export function readRecentWorkspaces() {
36
82
  const file = recentsFilePath();
37
83
  if (!existsSync(file)) return [];
@@ -44,11 +90,15 @@ export function readRecentWorkspaces() {
44
90
  const p = resolve(item.path);
45
91
  try {
46
92
  if (!existsSync(p) || !statSync(p).isDirectory()) continue;
93
+ const prof = detectWorkspaceProfile(p);
47
94
  out.push({
48
95
  path: p,
49
96
  name: basename(p) || p,
50
97
  hasClado: existsSync(join(p, '.clado')),
51
98
  isGit: existsSync(join(p, '.git')),
99
+ gitBranch: prof.gitBranch,
100
+ codeFiles: prof.codeFiles,
101
+ primaryLang: prof.primaryLang,
52
102
  documents: countMarkdownInWorkspace(p),
53
103
  lastOpenedAt: item.lastOpenedAt || new Date().toISOString(),
54
104
  });
@@ -221,3 +271,30 @@ export function createStarterCanvas(docRoot, { title = '系统架构概览', fil
221
271
  writeFileSync(fullPath, body, 'utf8');
222
272
  return { file: fileName, title: cleanTitle };
223
273
  }
274
+
275
+ export function renameCanvasDocument(docRoot, oldFile, newFileInput) {
276
+ const cleanOld = String(oldFile || '').trim();
277
+ if (!cleanOld) throw new DocumentError('请提供原画布文件名。', 400);
278
+ const oldPath = workspacePath(docRoot, cleanOld, false);
279
+ if (!existsSync(oldPath)) throw new DocumentError(`找不到画布:${cleanOld}`, 404);
280
+
281
+ let cleanNew = String(newFileInput || '').trim().replace(/\\/g, '/').replace(/^\/+/, '');
282
+ if (!cleanNew) throw new DocumentError('新画布名称不能为空。', 400);
283
+ if (!/\.mdc?$/i.test(cleanNew)) cleanNew += '.md';
284
+
285
+ const newPath = workspacePath(docRoot, cleanNew, true);
286
+ if (oldPath === newPath) return { oldFile: cleanOld, file: cleanNew };
287
+ if (existsSync(newPath)) throw new DocumentError(`目标画布已存在:${cleanNew}`, 409);
288
+ if (!existsSync(dirname(newPath))) mkdirSync(dirname(newPath), { recursive: true });
289
+ renameSync(oldPath, newPath);
290
+ return { oldFile: cleanOld, file: cleanNew };
291
+ }
292
+
293
+ export function deleteCanvasDocument(docRoot, file) {
294
+ const cleanFile = String(file || '').trim();
295
+ if (!cleanFile) throw new DocumentError('请提供要删除的画布文件名。', 400);
296
+ const targetPath = workspacePath(docRoot, cleanFile, false);
297
+ if (!existsSync(targetPath)) throw new DocumentError(`找不到画布:${cleanFile}`, 404);
298
+ rmSync(targetPath, { force: true });
299
+ return { deleted: cleanFile };
300
+ }
@@ -18,8 +18,11 @@ import { createWorkspaceEvents, broadcastMcpEvent } from './events.js';
18
18
  import {
19
19
  browseLocalFolders,
20
20
  createStarterCanvas,
21
+ deleteCanvasDocument,
22
+ detectWorkspaceProfile,
21
23
  readRecentWorkspaces,
22
24
  recordRecentWorkspace,
25
+ renameCanvasDocument,
23
26
  resolveWorkspaceSelection,
24
27
  } from './workspace-hub.js';
25
28
  import { z } from 'zod/v4';
@@ -75,7 +78,7 @@ export function createWorkspaceHandler(directory, options = {}) {
75
78
  }
76
79
  if (options.agent && url.pathname === '/library/agent/meta') {
77
80
  const target = resolveTarget(url);
78
- options.agent.handleMeta(req, res, target.workspace); return true;
81
+ await options.agent.handleMeta(req, res, target.workspace); return true;
79
82
  }
80
83
  if (options.agent && url.pathname === '/library/agent/sessions') {
81
84
  const target = resolveTarget(url);
@@ -206,6 +209,16 @@ export function createWorkspaceHandler(directory, options = {}) {
206
209
  json(res, 201, options.workspaceHub.createCanvas(target, body));
207
210
  return true;
208
211
  }
212
+ if (body?.action === 'rename_canvas') {
213
+ const target = resolveTarget(url);
214
+ json(res, 200, options.workspaceHub.renameCanvas(target, body));
215
+ return true;
216
+ }
217
+ if (body?.action === 'delete_canvas') {
218
+ const target = resolveTarget(url);
219
+ json(res, 200, options.workspaceHub.deleteCanvas(target, body));
220
+ return true;
221
+ }
209
222
  json(res, 200, options.workspaceHub.switchWorkspace(body?.path, body));
210
223
  return true;
211
224
  }
@@ -304,7 +317,7 @@ export function createWorkspaceHandler(directory, options = {}) {
304
317
  }
305
318
  };
306
319
  }
307
- export async function startWorkspace(input, { port = 4317, mode = 'cards', theme = 'light', entry, project = false, hubMode = false, experimentalPlugins = false, agent: agentName = 'acp' } = {}) {
320
+ export async function startWorkspace(input, { port = 4317, mode = 'cards', theme = 'light', entry, project = false, hubMode = false, experimentalPlugins = false, agent: agentName = 'pi' } = {}) {
308
321
  const path = resolve(input);
309
322
  if (!existsSync(path) && !/\.mdc?$/i.test(path)) mkdirSync(path, { recursive: true });
310
323
  if (statSync(path).isFile() && !/\.mdc?$/i.test(path)) throw new DocumentError('serve 文件需要 .mdc 或 .md 扩展名。');
@@ -395,12 +408,6 @@ export async function startWorkspace(input, { port = 4317, mode = 'cards', theme
395
408
  mcpUrl: liveMcpUrl,
396
409
  workspaceService: mcpService,
397
410
  events,
398
- resolveSettings: () => rootRuntime.settings.agentLaunch(),
399
- saveSettings: updater => {
400
- const cur = rootRuntime.settings.read('clado.agent');
401
- const next = updater(cur.value);
402
- return rootRuntime.settings.save('clado.agent', next, cur.value).value;
403
- },
404
411
  resolveRuntimeInfo: targetWorkspace => {
405
412
  const rt = runtimeFor(contextFor(workspace, targetWorkspace, root));
406
413
  return {
@@ -409,10 +416,6 @@ export async function startWorkspace(input, { port = 4317, mode = 'cards', theme
409
416
  pluginDescriptors: rt.plugins?.descriptor.plugins || [],
410
417
  };
411
418
  },
412
- ...(agentName === 'acp' && { resolveLaunch: () => {
413
- const { command, args, env } = rootRuntime.settings.agentLaunch();
414
- return { command, args, env };
415
- } }),
416
419
  }) : null;
417
420
  function installPlugin(targetWorkspace, files) {
418
421
  const rt = runtimeFor(contextFor(workspace, targetWorkspace, root));
@@ -438,6 +441,9 @@ export async function startWorkspace(input, { port = 4317, mode = 'cards', theme
438
441
  const removed = removeWorkspacePlugin(rt.ctx, id);
439
442
  if (rt.plugins) {
440
443
  rt.plugins.descriptor.plugins = rt.plugins.descriptor.plugins.filter(p => p.id !== removed.id);
444
+ rt.plugins.pluginDirs = (rt.plugins.pluginDirs || []).filter(p => p.id !== removed.id);
445
+ rt.plugins.pluginMcp = (rt.plugins.pluginMcp || []).filter(p => p.pluginId !== removed.id);
446
+ rt.plugins.pluginPersonas = (rt.plugins.pluginPersonas || []).filter(p => p.pluginId !== removed.id);
441
447
  rt.grants.delete(removed.id);
442
448
  rt.providers = rt.providers.filter(p => p.pluginId !== removed.id);
443
449
  }
@@ -495,6 +501,7 @@ export async function startWorkspace(input, { port = 4317, mode = 'cards', theme
495
501
  return {
496
502
  currentWorkspace: workspace,
497
503
  currentName: basename(workspace),
504
+ currentProfile: detectWorkspaceProfile(workspace),
498
505
  hubMode: activeHubMode,
499
506
  recentWorkspaces: readRecentWorkspaces(),
500
507
  ...browseLocalFolders(dir || workspace),
@@ -535,6 +542,16 @@ export async function startWorkspace(input, { port = 4317, mode = 'cards', theme
535
542
  events.emit(target.workspace, 'workspace.updated', { action: 'create_canvas', file: created.file });
536
543
  return { ok: true, ...created };
537
544
  },
545
+ renameCanvas(target, opts = {}) {
546
+ const renamed = renameCanvasDocument(target.root, opts.oldFile || opts.file, opts.newFile || opts.name);
547
+ events.emit(target.workspace, 'workspace.updated', { action: 'rename_canvas', oldFile: renamed.oldFile, file: renamed.file });
548
+ return { ok: true, ...renamed };
549
+ },
550
+ deleteCanvas(target, opts = {}) {
551
+ const removed = deleteCanvasDocument(target.root, opts.file);
552
+ events.emit(target.workspace, 'workspace.updated', { action: 'delete_canvas', file: removed.deleted });
553
+ return { ok: true, ...removed };
554
+ },
538
555
  };
539
556
  const handle = createWorkspaceHandler(root,{
540
557
  entrypoint:true,mode,theme,entry:entryFile,publishSelection,events,