cladogram 0.5.5-beta.6 → 0.5.5-beta.7

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.
@@ -69,6 +69,30 @@
69
69
  reloadWithMode(true);
70
70
  },
71
71
  },
72
+ market: config.canInstallPlugins ? {
73
+ load: async () => {
74
+ const response = await fetch(withWorkspace('/library/plugin-registry'), { cache: 'no-store' });
75
+ const result = await response.json();
76
+ if (!response.ok) throw new Error(result.error || '加载插件市场失败');
77
+ return result;
78
+ },
79
+ install: async id => {
80
+ const response = await fetch(withWorkspace('/library/plugin-registry'), {
81
+ method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id }),
82
+ });
83
+ const result = await response.json();
84
+ if (!response.ok) throw new Error(result.error || '安装失败');
85
+ return result;
86
+ },
87
+ uninstall: async id => {
88
+ const response = await fetch(withWorkspace('/library/install-plugin?id=' + encodeURIComponent(id)), {
89
+ method: 'DELETE',
90
+ });
91
+ const result = await response.json();
92
+ if (!response.ok) throw new Error(result.error || '卸载失败');
93
+ return result;
94
+ },
95
+ } : null,
72
96
  setTheme: theme => {
73
97
  if (modalLocked()) return;
74
98
  try { localStorage.setItem('clado-theme', theme); } catch {}
@@ -119,6 +143,277 @@
119
143
  }
120
144
  const selectionTab = config.selection ? crypto.randomUUID() : null;
121
145
  let aiSelection = null, selectionRequest = Promise.resolve(), pageHidden = false;
146
+ const liveObjectsEnabled = Boolean(config.selection && !offline && document.body);
147
+ let canvasObjectsList = [];
148
+ const objectSelection = new Map();
149
+ let selectionBarEl = null;
150
+ let canvasCtxMenuEl = null;
151
+
152
+ function syncFrameObjects() {
153
+ if (!liveObjectsEnabled || !frame?.contentWindow) return;
154
+ try {
155
+ frame.contentWindow.postMessage({ type: 'clado-workspace:objects', objects: canvasObjectsList }, location.origin);
156
+ frame.contentWindow.postMessage({ type: 'clado-workspace:object-selection', keys: [...objectSelection.keys()] }, location.origin);
157
+ } catch {}
158
+ }
159
+
160
+ function collectSelectionLabels() {
161
+ const cardLabels = (aiSelection?.nodes || []).map(node => Array.isArray(node) ? node[node.length - 1] : String(node));
162
+ const objLabels = [...objectSelection.values()].map(item => item.title || item.id);
163
+ return [...cardLabels, ...objLabels];
164
+ }
165
+
166
+ function renderSelectionSummary() {
167
+ if (!selectionBarEl) return;
168
+ const labels = collectSelectionLabels();
169
+ if (!labels.length) {
170
+ selectionBarEl.classList.remove('show');
171
+ return;
172
+ }
173
+ const preview = labels.slice(0, 3).join(' / ') + (labels.length > 3 ? '…' : '');
174
+ selectionBarEl.querySelector('[data-sel-summary]').textContent = `已选 ${labels.length} 项 · ${preview}`;
175
+ selectionBarEl.classList.add('show');
176
+ }
177
+
178
+ async function loadObjects() {
179
+ if (!liveObjectsEnabled) return;
180
+ try {
181
+ const res = await fetch(withWorkspace('/library/objects'), { cache: 'no-store' });
182
+ if (!res.ok) return;
183
+ const data = await res.json();
184
+ if (Array.isArray(data.objects)) {
185
+ canvasObjectsList = data.objects;
186
+ const validIds = new Set(canvasObjectsList.map(o => o.id));
187
+ for (const [k, v] of objectSelection) {
188
+ if (!validIds.has(v.id)) objectSelection.delete(k);
189
+ }
190
+ syncFrameObjects();
191
+ renderSelectionSummary();
192
+ }
193
+ } catch {}
194
+ }
195
+
196
+ async function saveObject(payload) {
197
+ if (!liveObjectsEnabled) return null;
198
+ try {
199
+ const res = await fetch(withWorkspace('/library/objects'), {
200
+ method: 'POST',
201
+ headers: { 'content-type': 'application/json' },
202
+ body: JSON.stringify(payload),
203
+ });
204
+ if (!res.ok) return null;
205
+ const data = await res.json();
206
+ if (data.object) {
207
+ const idx = canvasObjectsList.findIndex(o => o.id === data.object.id);
208
+ if (idx >= 0) canvasObjectsList[idx] = data.object;
209
+ else canvasObjectsList.push(data.object);
210
+ syncFrameObjects();
211
+ renderSelectionSummary();
212
+ }
213
+ return data.object;
214
+ } catch { return null; }
215
+ }
216
+
217
+ async function deleteObject(id) {
218
+ if (!liveObjectsEnabled || !id) return;
219
+ try {
220
+ const res = await fetch(withWorkspace('/library/objects'), {
221
+ method: 'POST',
222
+ headers: { 'content-type': 'application/json' },
223
+ body: JSON.stringify({ action: 'delete', id }),
224
+ });
225
+ if (!res.ok) return;
226
+ canvasObjectsList = canvasObjectsList.filter(o => o.id !== id);
227
+ for (const [k, v] of objectSelection) {
228
+ if (v.id === id) objectSelection.delete(k);
229
+ }
230
+ syncFrameObjects();
231
+ renderSelectionSummary();
232
+ } catch {}
233
+ }
234
+
235
+ function closeCanvasCtxMenu() {
236
+ canvasCtxMenuEl?.classList.remove('show');
237
+ }
238
+
239
+ function openCanvasCtxMenu(clientX, clientY, detail) {
240
+ if (!canvasCtxMenuEl || !detail) return;
241
+ canvasCtxMenuEl.innerHTML = '';
242
+ const addLabel = text => {
243
+ const lbl = document.createElement('div');
244
+ lbl.className = 'clado-canvas-ctx-head';
245
+ lbl.textContent = text;
246
+ canvasCtxMenuEl.append(lbl);
247
+ };
248
+ const addSep = () => {
249
+ const hr = document.createElement('div');
250
+ hr.className = 'clado-canvas-ctx-sep';
251
+ canvasCtxMenuEl.append(hr);
252
+ };
253
+ const addItem = (label, onClick, danger = false) => {
254
+ const btn = document.createElement('button');
255
+ btn.type = 'button';
256
+ btn.className = 'clado-canvas-ctx-item' + (danger ? ' danger' : '');
257
+ btn.textContent = label;
258
+ btn.onclick = () => {
259
+ closeCanvasCtxMenu();
260
+ onClick();
261
+ };
262
+ canvasCtxMenuEl.append(btn);
263
+ };
264
+
265
+ if (detail.kind === 'subtarget' && detail.object) {
266
+ const obj = canvasObjectsList.find(o => o.id === detail.object.id) || detail.object;
267
+ const shortTitle = String(detail.trackTitle || '').split(' · ')[0] || detail.trackId;
268
+ const selKey = `sub:${obj.id}:${detail.trackId}`;
269
+ const isSelected = objectSelection.has(selKey);
270
+ const isCustom = obj.data?.selRenderMode === 'custom';
271
+ addLabel(`子目标 · ${shortTitle}`);
272
+ addItem(detail.liked ? '♥ 移除喜欢' : '♡ 加入喜欢', () => {
273
+ const tracks = (obj.data?.tracks || []).map(t => t.id === detail.trackId ? { ...t, liked: !t.liked } : t);
274
+ saveObject({ ...obj, data: { ...(obj.data || {}), tracks } });
275
+ });
276
+ addItem(isSelected ? '取消选中这首歌' : '选中这首歌', () => {
277
+ if (isSelected) objectSelection.delete(selKey);
278
+ else objectSelection.set(selKey, { id: obj.id, kind: obj.kind, title: shortTitle, pluginId: obj.pluginId, subtarget: detail.trackId });
279
+ syncFrameObjects();
280
+ renderSelectionSummary();
281
+ });
282
+ addSep();
283
+ addItem(isCustom ? '切换为默认高亮选态' : '切换为自绘音波选态', () => {
284
+ saveObject({ ...obj, data: { ...(obj.data || {}), selRenderMode: isCustom ? 'default' : 'custom' } });
285
+ });
286
+ } else if (detail.kind === 'object' && detail.object) {
287
+ const obj = canvasObjectsList.find(o => o.id === detail.object.id) || detail.object;
288
+ const selKey = `obj:${obj.id}`;
289
+ const isSelected = objectSelection.has(selKey);
290
+ if (obj.kind === 'sticky') {
291
+ addLabel(`便签 · #${obj.id}`);
292
+ addItem(isSelected ? '取消选中便签' : '选中此便签', () => {
293
+ if (isSelected) objectSelection.delete(selKey);
294
+ else objectSelection.set(selKey, { id: obj.id, kind: 'sticky', title: obj.title || `便签 #${obj.id}`, pluginId: obj.pluginId });
295
+ syncFrameObjects();
296
+ renderSelectionSummary();
297
+ });
298
+ addItem('编辑便签内容', () => {
299
+ try { frame.contentWindow.postMessage({ type: 'clado-workspace:edit-sticky', id: obj.id }, location.origin); } catch {}
300
+ });
301
+ addItem('切换便签颜色', () => {
302
+ const tints = ['amber', 'mint', 'lavender', 'sky'];
303
+ const nextTint = tints[(tints.indexOf(obj.tint || 'amber') + 1) % tints.length];
304
+ saveObject({ ...obj, tint: nextTint });
305
+ });
306
+ addSep();
307
+ addItem('删除此便签', () => deleteObject(obj.id), true);
308
+ } else {
309
+ const isCustom = obj.data?.selRenderMode === 'custom';
310
+ const isExpanded = Boolean(obj.data?.expanded);
311
+ addLabel(`组件 · ${obj.title || obj.id}`);
312
+ addItem(isSelected ? '取消选中组件' : '选中此组件', () => {
313
+ if (isSelected) objectSelection.delete(selKey);
314
+ else objectSelection.set(selKey, { id: obj.id, kind: obj.kind, title: obj.title || obj.id, pluginId: obj.pluginId });
315
+ syncFrameObjects();
316
+ renderSelectionSummary();
317
+ });
318
+ addItem(isCustom ? '切换为默认高亮选态' : '切换为自绘音波选态', () => {
319
+ saveObject({ ...obj, data: { ...(obj.data || {}), selRenderMode: isCustom ? 'default' : 'custom' } });
320
+ });
321
+ addItem(isExpanded ? '还原组件大小' : '放大组件卡片', () => {
322
+ saveObject({ ...obj, data: { ...(obj.data || {}), expanded: !isExpanded } });
323
+ });
324
+ addSep();
325
+ addItem('删除此组件', () => deleteObject(obj.id), true);
326
+ }
327
+ } else if (detail.kind === 'card' && detail.node) {
328
+ const nodes = [...(aiSelection?.nodes || [])];
329
+ const at = nodes.findIndex(n => JSON.stringify(n) === JSON.stringify(detail.node));
330
+ addLabel(`卡片 · ${detail.title || detail.node[detail.node.length - 1]}`);
331
+ addItem(at >= 0 ? '取消选中此卡片' : '选中此卡片', () => {
332
+ const nextNodes = [...(aiSelection?.nodes || [])];
333
+ const idx = nextNodes.findIndex(n => JSON.stringify(n) === JSON.stringify(detail.node));
334
+ if (idx >= 0) nextNodes.splice(idx, 1);
335
+ else nextNodes.push(detail.node);
336
+ setSelection(nextNodes.length ? { file: selected, version, nodes: nextNodes } : null);
337
+ });
338
+ addItem('旁边贴一张便签', () => {
339
+ saveObject({ kind: 'sticky', title: '设计便签', pluginId: 'starter.sticky-notes', x: detail.wx, y: detail.wy, tint: 'amber', text: '记录设计要点…' });
340
+ });
341
+ } else {
342
+ addLabel('画布空白处');
343
+ addItem('+ 在此处新建便签', () => {
344
+ saveObject({ kind: 'sticky', title: '灵感便签', pluginId: 'starter.sticky-notes', x: detail.wx, y: detail.wy, tint: 'amber', text: '记录一条新想法…' });
345
+ });
346
+ addItem('+ 添加专注播放器组件', () => {
347
+ saveObject({
348
+ kind: 'music',
349
+ title: 'Lo-Fi 专注播放器',
350
+ pluginId: 'starter.lofi-player',
351
+ x: detail.wx,
352
+ y: detail.wy,
353
+ width: 326,
354
+ data: {
355
+ expanded: false,
356
+ selRenderMode: 'custom',
357
+ tracks: [
358
+ { id: 't1', title: 'Midnight Rain · 深夜雨声', duration: '03:24', liked: true },
359
+ { id: 't2', title: 'Glass Horizon · 玻璃天际线', duration: '02:58', liked: false },
360
+ { id: 't3', title: 'Soft Focus · 柔焦白噪音', duration: '04:12', liked: false },
361
+ ],
362
+ },
363
+ });
364
+ });
365
+ addSep();
366
+ addItem('居中复位画布', () => frame.contentWindow.CladoPrototype?.fit());
367
+ }
368
+
369
+ canvasCtxMenuEl.style.left = '10px';
370
+ canvasCtxMenuEl.style.top = '10px';
371
+ canvasCtxMenuEl.classList.add('show');
372
+ const menuW = canvasCtxMenuEl.offsetWidth || 186;
373
+ const menuH = canvasCtxMenuEl.offsetHeight || 160;
374
+ const clampedX = Math.max(10, Math.min(clientX, window.innerWidth - menuW - 10));
375
+ const clampedY = Math.max(10, Math.min(clientY, window.innerHeight - menuH - 10));
376
+ canvasCtxMenuEl.style.left = clampedX + 'px';
377
+ canvasCtxMenuEl.style.top = clampedY + 'px';
378
+ }
379
+
380
+ if (liveObjectsEnabled) {
381
+ selectionBarEl = document.createElement('div');
382
+ selectionBarEl.id = 'clado-selection-bar';
383
+ selectionBarEl.className = 'clado-selection-bar';
384
+ selectionBarEl.innerHTML = `
385
+ <span class="clado-selection-dot"></span>
386
+ <span class="clado-selection-text" data-sel-summary>已选 0 项</span>
387
+ <button type="button" class="clado-selection-send" data-sel-send>发给当前会话</button>
388
+ <button type="button" class="clado-selection-clear" data-sel-clear>完成</button>`;
389
+ selectionBarEl.querySelector('[data-sel-send]').onclick = () => {
390
+ const names = collectSelectionLabels().join('、');
391
+ window.dispatchEvent(new CustomEvent('clado:send-selection', { detail: { names } }));
392
+ };
393
+ selectionBarEl.querySelector('[data-sel-clear]').onclick = () => {
394
+ objectSelection.clear();
395
+ if (aiSelection) setSelection(null);
396
+ syncFrameObjects();
397
+ renderSelectionSummary();
398
+ };
399
+ document.body.append(selectionBarEl);
400
+
401
+ canvasCtxMenuEl = document.createElement('div');
402
+ canvasCtxMenuEl.id = 'clado-canvas-ctx-menu';
403
+ canvasCtxMenuEl.className = 'clado-canvas-ctx-menu';
404
+ document.body.append(canvasCtxMenuEl);
405
+
406
+ document.addEventListener('pointerdown', ev => {
407
+ if (canvasCtxMenuEl.classList.contains('show') && !ev.target.closest?.('#clado-canvas-ctx-menu')) {
408
+ closeCanvasCtxMenu();
409
+ }
410
+ }, true);
411
+ document.addEventListener('keydown', ev => {
412
+ if (ev.key === 'Escape') closeCanvasCtxMenu();
413
+ });
414
+ loadObjects();
415
+ }
416
+
122
417
  let readyCanvas = null;
123
418
  const canvasWaiters = new Set();
124
419
  function readScreenshotCanvas() {
@@ -160,10 +455,11 @@
160
455
  setFollowAi,
161
456
  focusTarget,
162
457
  readCanvas() {
163
- if (readyCanvas?.frame !== frame) return undefined;
458
+ const objSel = objectSelection.size ? [...objectSelection.values()] : undefined;
459
+ if (readyCanvas?.frame !== frame) return objSel ? { objectSelection: objSel } : undefined;
164
460
  const { file, revision } = readyCanvas;
165
461
  const selection = aiSelection?.file === file && aiSelection.version === revision ? aiSelection.nodes : [];
166
- return { file, revision, selection };
462
+ return { file, revision, selection, ...(objSel ? { objectSelection: objSel } : {}) };
167
463
  },
168
464
  viewId: capabilities?.viewId,
169
465
  });
@@ -180,6 +476,7 @@
180
476
  });
181
477
  function showSelection() {
182
478
  if (selectionTab) frame.contentWindow.postMessage({ type: 'clado-workspace:selection', nodes: aiSelection?.nodes || [] }, location.origin);
479
+ renderSelectionSummary();
183
480
  }
184
481
  async function publishSelection(selection) {
185
482
  const response = await fetch(withWorkspace('/library/selection'), { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ tab: selectionTab, ...selection }), keepalive: true });
@@ -404,16 +701,33 @@
404
701
  setSelection(nodes.length ? { file: selected, version, nodes } : null);
405
702
  return;
406
703
  }
704
+ if (liveObjectsEnabled && data?.type === 'clado-library:object-save' && data.object) {
705
+ const existing = canvasObjectsList.find(o => o.id === data.object.id);
706
+ saveObject(existing ? { ...existing, ...data.object } : data.object);
707
+ return;
708
+ }
709
+ if (liveObjectsEnabled && data?.type === 'clado-library:object-toggle-select' && data.key) {
710
+ if (objectSelection.has(data.key)) objectSelection.delete(data.key);
711
+ else if (data.item) objectSelection.set(data.key, data.item);
712
+ syncFrameObjects();
713
+ renderSelectionSummary();
714
+ return;
715
+ }
716
+ if (liveObjectsEnabled && data?.type === 'clado-library:context-menu' && data.detail) {
717
+ const rect = frame.getBoundingClientRect?.() || { left: 0, top: 0 };
718
+ openCanvasCtxMenu((rect.left || 0) + (data.x || 0), (rect.top || 0) + (data.y || 0), data.detail);
719
+ return;
720
+ }
407
721
  if (data?.type === 'clado-library:chain-modal') { chainLock(data.value, data.mode); return; }
408
722
  if (data?.type === 'clado-library:lens-modal') {
409
723
  lensOpen = !!data.value;
410
- if (lensOpen) { brand.close(); directory.close(); }
724
+ if (lensOpen) { brand.close(); directory.close(); closeCanvasCtxMenu(); }
411
725
  host.setHidden(chainModal || lensOpen);
412
726
  return;
413
727
  }
414
728
  if(modalLocked() && ['clado-library:open','clado-library:ready','clado-library:missing'].includes(data?.type))return;
415
- if (data?.type === 'clado-library:open') { directory.close(); open(data.target, data.anchor); }
416
- else if (data?.type === 'clado-library:dismiss-directory') { brand.close(); directory.close(); }
729
+ if (data?.type === 'clado-library:open') { directory.close(); closeCanvasCtxMenu(); open(data.target, data.anchor); }
730
+ else if (data?.type === 'clado-library:dismiss-directory') { brand.close(); directory.close(); closeCanvasCtxMenu(); }
417
731
  else if (data?.type === 'clado-library:missing') directory.showMessage('链接超出当前目录', '请选择当前工作区中的文档。链接:' + data.target);
418
732
  else if (data?.type === 'clado-library:view-state') syncChrome();
419
733
  else if (data?.type === 'clado-library:ready') {
@@ -435,6 +749,7 @@
435
749
  setSelection(nodes.length ? { file: selected, version: data.version, nodes } : null, nodes.length > 0);
436
750
  }
437
751
  showSelection();
752
+ syncFrameObjects();
438
753
  if(offline){frame.contentWindow.postMessage({type:'clado-workspace:display',mode,theme:design.theme,anchor:pendingAnchor},'*');pendingAnchor='';}
439
754
  else if (mode !== data.mode) frame.contentWindow.CladoPrototype?.setMode?.(mode);
440
755
  saveView(); $('#canvasLoading').hidden = true; syncChrome();
@@ -469,6 +784,7 @@
469
784
  scan(true);
470
785
  });
471
786
  es.addEventListener('workspace.updated', () => scan(true));
787
+ es.addEventListener('objects.updated', () => { if (liveObjectsEnabled) loadObjects(); });
472
788
  es.addEventListener('agent.activity', event => {
473
789
  try {
474
790
  const payload = JSON.parse(event.data || '{}');
@@ -484,6 +800,14 @@
484
800
  focusTarget(payload.file || selected, payload.nodes?.[0] || null, payload.label || '');
485
801
  } catch {}
486
802
  });
803
+ es.addEventListener('agent.sessions', event => {
804
+ try {
805
+ const payload = JSON.parse(event.data || '{}');
806
+ if (typeof CustomEvent === 'function') {
807
+ dispatchEvent(new CustomEvent('clado:agent-sessions', { detail: payload }));
808
+ }
809
+ } catch {}
810
+ });
487
811
  es.onerror = () => { sseReady = false; };
488
812
  addEventListener('pagehide', () => es.close());
489
813
  } catch {}
@@ -19,6 +19,10 @@ const registryEntrySchema = z.strictObject({
19
19
  version: z.string().min(1).max(64),
20
20
  description: z.string().max(400).default(''),
21
21
  category: z.enum(['ui', 'executor', 'template', 'view', 'renderer']).default('ui'),
22
+ kind: z.enum(['multi', 'tool', 'hybrid', 'executor', 'ui']).optional(),
23
+ source: z.enum(['official', 'team']).optional(),
24
+ icon: z.string().max(16).optional(),
25
+ readme: z.string().max(4000).optional(),
22
26
  author: z.string().max(80).default('community'),
23
27
  engines: z.strictObject({ clado: z.string().min(1).max(120) }).default({ clado: '^0.5.4' }),
24
28
  permissions: z.array(z.string().max(120)).max(64).default([]),
@@ -58,6 +62,9 @@ export function auditPluginPermissions(manifestData = {}) {
58
62
  for (const exec of executors) {
59
63
  items.push({ permission: `acp.executor:${exec.id}`, risk: 'high', summary: `注册本机 ACP 开发执行器:${exec.name || exec.id} (${exec.command})` });
60
64
  }
65
+ if (!executors.length && manifestData.category === 'executor') {
66
+ items.push({ permission: 'acp.executor', risk: 'high', summary: '注册本机 ACP 开发执行器进程' });
67
+ }
61
68
  const highestRisk = items.some(i => i.risk === 'high') ? 'high' : items.some(i => i.risk === 'medium') ? 'medium' : 'low';
62
69
  return { highestRisk, items };
63
70
  }
@@ -277,21 +284,57 @@ const DEFAULT_REGISTRY = {
277
284
  registryVersion: 1,
278
285
  name: 'Clado Built-in Starter Catalog',
279
286
  plugins: [
287
+ {
288
+ id: 'starter.sticky-notes',
289
+ name: '画布便签',
290
+ version: '1.2.0',
291
+ icon: '📌',
292
+ kind: 'multi',
293
+ source: 'official',
294
+ description: '在画布任意位置贴多张独立便签,支持长按切换色卡、多选汇总并让 AI 按 ID 单独或批量读取修改。',
295
+ readme: '数据以结构化 JSON 持久化于子工作区 `.clado/objects/`,长按画布空白或卡片即可贴便签,长按便签可选中并发给当前 Agent 会话。',
296
+ category: 'ui',
297
+ author: 'Clado Labs',
298
+ engines: { clado: '^0.5.4' },
299
+ permissions: ['ui.mount:sidebar', 'canvas.document.read', 'canvas.selection.read'],
300
+ },
280
301
  {
281
302
  id: 'starter.review-sidebar',
282
303
  name: '画布评审侧栏(官方脚手架示例)',
283
304
  version: '0.1.0',
305
+ icon: '🧭',
306
+ kind: 'tool',
307
+ source: 'official',
284
308
  description: '展示如何读取画布文档与选区并向 AI 暴露结构化能力;可通过 clado plugin create --kind ui 一键生成。',
309
+ readme: '只读访问当前打开画布标题与选中节点数量,并注册 `inspect.summary` 能力供 Agent 调用。',
285
310
  category: 'ui',
286
311
  author: 'Clado',
287
312
  engines: { clado: '^0.5.4' },
288
313
  permissions: ['ui.mount:sidebar', 'canvas.document.read', 'canvas.selection.read'],
289
314
  },
315
+ {
316
+ id: 'starter.lofi-player',
317
+ name: 'Lo-Fi 专注播放器',
318
+ version: '1.0.0',
319
+ icon: '♫',
320
+ kind: 'hybrid',
321
+ source: 'team',
322
+ description: '视图+工具双级长按示例:长按外框调整组件尺寸,长按歌名子区域独立切换喜欢或自绘音波选中态。',
323
+ readme: '演示多实例容器与内部 `data-subtarget` 子区域靶点的双级上下文菜单及自绘音波选中态。',
324
+ category: 'ui',
325
+ author: 'Community',
326
+ engines: { clado: '^0.5.4' },
327
+ permissions: ['ui.mount:sidebar', 'canvas.selection.read'],
328
+ },
290
329
  {
291
330
  id: 'starter.acp-executor',
292
331
  name: 'ACP 外包编码执行器(官方脚手架示例)',
293
332
  version: '0.1.0',
333
+ icon: '⚡',
334
+ kind: 'executor',
335
+ source: 'official',
294
336
  description: '将画布设计规格一键派发给外部 ACP 编码 Agent(Codex / Claude Code / Gemini CLI 等);可通过 clado plugin create --kind executor 一键生成。',
337
+ readme: '高敏执行器级插件,安装前自动展示进程调用权限审计清单,支持在会话详情「派发开发」中直接调用。',
295
338
  category: 'executor',
296
339
  author: 'Clado',
297
340
  engines: { clado: '^0.5.4' },
@@ -300,6 +343,60 @@ const DEFAULT_REGISTRY = {
300
343
  ],
301
344
  };
302
345
 
346
+ export function buildCatalogPluginFiles(entry) {
347
+ const isExecutor = entry.category === 'executor' || entry.kind === 'executor';
348
+ const manifest = {
349
+ manifestVersion: 1,
350
+ id: entry.id,
351
+ name: entry.name,
352
+ version: entry.version || '0.1.0',
353
+ engines: entry.engines || { clado: '^0.5.4' },
354
+ protocols: ['1.0'],
355
+ entrypoints: { ui: { path: 'ui/index.html' } },
356
+ permissions: entry.permissions?.length ? entry.permissions : ['ui.mount:sidebar', 'canvas.document.read'],
357
+ contributes: {
358
+ mounts: [{ id: 'panel', slot: 'sidebar' }],
359
+ capabilities: [],
360
+ ...(isExecutor ? {
361
+ executors: [{
362
+ id: entry.id.replace(/\./g, '-') + '-acp',
363
+ name: entry.name,
364
+ protocol: 'acp',
365
+ command: 'echo',
366
+ args: [`[${entry.name}] Ready`],
367
+ capabilities: ['code.implement', 'test.run'],
368
+ description: entry.description || '',
369
+ }],
370
+ } : {}),
371
+ },
372
+ };
373
+ const html = `<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><link rel="stylesheet" href="/plugin-ui.css"><link rel="stylesheet" href="./style.css"></head><body><div class="card"><strong>${entry.name}</strong><p>${entry.description || ''}</p></div><script src="/clado-plugin-sdk.js"></script><script src="./main.js"></script></body></html>`;
374
+ const js = `window.CladoPlugin?.ready?.catch?.(() => {});\n`;
375
+ const css = `.card{padding:12px;font-size:12.5px;line-height:1.5}.card p{margin:6px 0 0;color:var(--clado-ui-muted,#667085)}`;
376
+ const b64 = s => Buffer.from(s, 'utf8').toString('base64');
377
+ return {
378
+ files: [
379
+ { path: 'clado-plugin.json', data: b64(JSON.stringify(manifest, null, 2) + '\n') },
380
+ { path: 'ui/index.html', data: b64(html) },
381
+ { path: 'ui/main.js', data: b64(js) },
382
+ { path: 'ui/style.css', data: b64(css) },
383
+ ],
384
+ audit: auditPluginPermissions(manifest),
385
+ };
386
+ }
387
+
388
+ export async function installCatalogPlugin(ctx, id, { runtime = null, registry = '', fetchImpl = fetch } = {}) {
389
+ const reg = await loadRegistryIndex({ registry, stateDir: ctx.state, fetchImpl });
390
+ const entry = reg.plugins.find(p => p.id === id);
391
+ if (!entry) fail(`未在插件市场中找到插件:${id}`, 404);
392
+ if (entry.sourceDir) {
393
+ return installPluginFromDirectory(ctx, entry.sourceDir, runtime);
394
+ }
395
+ const { files, audit } = buildCatalogPluginFiles(entry);
396
+ const installed = installWorkspacePlugin(ctx, files, runtime);
397
+ return { ...installed, audit };
398
+ }
399
+
303
400
  export async function loadRegistryIndex({ registry = '', stateDir = '', fetchImpl = fetch } = {}) {
304
401
  const source = registry || process.env.CLADO_PLUGIN_REGISTRY || (stateDir && existsSync(join(stateDir, 'plugin-registry.json')) ? join(stateDir, 'plugin-registry.json') : '');
305
402
  let rawData = DEFAULT_REGISTRY;
@@ -340,5 +437,6 @@ export function searchRegistry(registryData, query = '') {
340
437
  || item.name.toLowerCase().includes(q)
341
438
  || item.description.toLowerCase().includes(q)
342
439
  || item.category.toLowerCase().includes(q)
440
+ || (item.kind && item.kind.toLowerCase().includes(q))
343
441
  );
344
442
  }
@@ -21,7 +21,7 @@ const specs = {
21
21
  baseUrl: { type: 'string', minLength: 1, maxLength: 512 },
22
22
  apiKey: { type: 'string', maxLength: 512 },
23
23
  model: { type: 'string', minLength: 1, maxLength: 128 },
24
- persona: { enum: ['architect', 'qa', 'auditor', 'custom'] },
24
+ persona: { enum: ['architect', 'coder', 'qa', 'auditor', 'custom'] },
25
25
  personaPrompt: { type: 'string', maxLength: 4000 },
26
26
  command: { type: 'string', minLength: 1, maxLength: 2048, pattern: '^.+' },
27
27
  args: { type: 'array', maxItems: 32, items: { type: 'string', maxLength: 2048 } },