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.
- package/README.md +102 -79
- package/bin/clado.js +1 -1
- package/docs/release.md +14 -0
- package/package.json +3 -3
- package/plugins/agent/index.js +906 -2535
- package/plugins/agent/style.css +381 -1388
- package/plugins/brand/index.js +84 -466
- package/plugins/brand/style.css +39 -172
- package/plugins/directory/index.js +33 -11
- package/plugins/directory/style.css +47 -0
- package/plugins/view-controls/index.js +17 -1
- package/plugins/view-controls/style.css +47 -29
- package/src/agent/clado-tools.js +299 -0
- package/src/agent/pi-bridge.js +487 -0
- package/src/agent/pi-config.js +630 -0
- package/src/html/plugin-ui.css +159 -134
- package/src/html/plugin-ui.js +3 -2
- package/src/server/agent.js +339 -1431
- package/src/server/assets/library.css +396 -11
- package/src/server/assets/library.html +37 -4
- package/src/server/assets/library.js +474 -203
- package/src/server/plugin-registry.js +7 -7
- package/src/server/plugins.js +62 -10
- package/src/server/workspace-hub.js +78 -1
- package/src/server/workspace.js +29 -12
- package/src/agent/context.js +0 -430
- package/src/agent/executors.js +0 -213
- package/src/agent/probe.js +0 -234
- package/src/agent/providers/anthropic.js +0 -220
- package/src/agent/providers/index.js +0 -235
- package/src/agent/providers/openai.js +0 -146
- package/src/agent/runtime.js +0 -947
- package/src/agent/sessions.js +0 -336
|
@@ -45,65 +45,131 @@
|
|
|
45
45
|
if (write) reloadWithMode(id !== 'clado.view-controls');
|
|
46
46
|
return result;
|
|
47
47
|
}
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
48
|
+
const stageEl = document.getElementById?.('clado-stage') || document.body;
|
|
49
|
+
const viewportEl = document.getElementById?.('clado-viewport') || null;
|
|
50
|
+
|
|
51
|
+
// ============ Toast Notification ============
|
|
52
|
+
let toastTimer = null;
|
|
53
|
+
function showToast(msg) {
|
|
54
|
+
const el = document.getElementById?.('clado-toast');
|
|
55
|
+
if (!el || !msg) return;
|
|
56
|
+
el.innerHTML = '<span class="clado-dot-sky"></span><span></span>';
|
|
57
|
+
el.querySelector('span:last-child').textContent = String(msg);
|
|
58
|
+
el.classList.add('show');
|
|
59
|
+
clearTimeout(toastTimer);
|
|
60
|
+
toastTimer = setTimeout(() => el.classList.remove('show'), 2400);
|
|
61
|
+
}
|
|
62
|
+
window.addEventListener?.('clado:toast', ev => showToast(ev.detail?.message));
|
|
63
|
+
|
|
64
|
+
// ============ Mobile Proportional Scale-to-Fit Stage (Zero Squish!) ============
|
|
65
|
+
if (viewportEl && stageEl && stageEl.id === 'clado-stage') {
|
|
66
|
+
const STAGE_W = 1280, STAGE_H = 820;
|
|
67
|
+
const mzLabel = document.querySelector('[data-mz-fit]');
|
|
68
|
+
let isScaled = false, fitScale = 1, curScale = 1, panX = 0, panY = 0;
|
|
69
|
+
|
|
70
|
+
const applyStageTransform = () => {
|
|
71
|
+
if (!isScaled) { stageEl.style.transform = ''; return; }
|
|
72
|
+
stageEl.style.transform = `translate3d(${panX.toFixed(1)}px, ${panY.toFixed(1)}px, 0) scale(${curScale.toFixed(4)})`;
|
|
73
|
+
if (mzLabel) mzLabel.textContent = Math.round(curScale * 100) + '%';
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const resetMobileFit = () => {
|
|
77
|
+
const vw = window.innerWidth, vh = window.innerHeight;
|
|
78
|
+
if (vw >= 1160) {
|
|
79
|
+
isScaled = false;
|
|
80
|
+
viewportEl.classList.remove('scaled-mode');
|
|
81
|
+
stageEl.style.transform = '';
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
isScaled = true;
|
|
85
|
+
viewportEl.classList.add('scaled-mode');
|
|
86
|
+
const padX = 12, padTop = 14, padBottom = 58;
|
|
87
|
+
fitScale = Math.min((vw - padX * 2) / STAGE_W, (vh - padTop - padBottom) / STAGE_H);
|
|
88
|
+
curScale = fitScale;
|
|
89
|
+
panX = (vw - STAGE_W * curScale) / 2;
|
|
90
|
+
panY = padTop + Math.max(0, (vh - padTop - padBottom - STAGE_H * curScale) / 2);
|
|
91
|
+
applyStageTransform();
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const stepZoom = delta => {
|
|
95
|
+
if (!isScaled) return;
|
|
96
|
+
const vw = window.innerWidth, vh = window.innerHeight;
|
|
97
|
+
const next = Math.max(fitScale * 0.85, Math.min(1.6, curScale + delta));
|
|
98
|
+
const ratio = next / curScale;
|
|
99
|
+
panX = vw / 2 - (vw / 2 - panX) * ratio;
|
|
100
|
+
panY = vh / 2 - (vh / 2 - panY) * ratio;
|
|
101
|
+
curScale = next;
|
|
102
|
+
applyStageTransform();
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
document.querySelector('[data-mz-out]')?.addEventListener('click', () => stepZoom(-0.15));
|
|
106
|
+
document.querySelector('[data-mz-in]')?.addEventListener('click', () => stepZoom(0.15));
|
|
107
|
+
mzLabel?.addEventListener('click', resetMobileFit);
|
|
108
|
+
|
|
109
|
+
const ptrs = new Map();
|
|
110
|
+
let lastDist = null, lastDrag = null;
|
|
111
|
+
viewportEl.addEventListener('pointerdown', e => {
|
|
112
|
+
if (!isScaled || e.target.closest('#clado-mobile-zoom-hud')) return;
|
|
113
|
+
ptrs.set(e.pointerId, { x: e.clientX, y: e.clientY });
|
|
114
|
+
if (ptrs.size === 1) lastDrag = { x: e.clientX, y: e.clientY };
|
|
115
|
+
else if (ptrs.size === 2) {
|
|
116
|
+
const p = [...ptrs.values()];
|
|
117
|
+
lastDist = Math.hypot(p[0].x - p[1].x, p[0].y - p[1].y);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
viewportEl.addEventListener('pointermove', e => {
|
|
121
|
+
if (!isScaled || !ptrs.has(e.pointerId)) return;
|
|
122
|
+
ptrs.set(e.pointerId, { x: e.clientX, y: e.clientY });
|
|
123
|
+
if (ptrs.size === 2) {
|
|
124
|
+
const p = [...ptrs.values()];
|
|
125
|
+
const dist = Math.hypot(p[0].x - p[1].x, p[0].y - p[1].y);
|
|
126
|
+
const mx = (p[0].x + p[1].x) / 2, my = (p[0].y + p[1].y) / 2;
|
|
127
|
+
if (lastDist && dist > 10) {
|
|
128
|
+
const next = Math.max(fitScale * 0.85, Math.min(1.8, curScale * (dist / lastDist)));
|
|
129
|
+
const ratio = next / curScale;
|
|
130
|
+
panX = mx - (mx - panX) * ratio;
|
|
131
|
+
panY = my - (my - panY) * ratio;
|
|
132
|
+
curScale = next;
|
|
133
|
+
applyStageTransform();
|
|
67
134
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}),
|
|
135
|
+
lastDist = dist;
|
|
136
|
+
} else if (ptrs.size === 1 && lastDrag && curScale > fitScale * 1.05) {
|
|
137
|
+
const dx = e.clientX - lastDrag.x, dy = e.clientY - lastDrag.y;
|
|
138
|
+
if (Math.hypot(dx, dy) > 2) {
|
|
139
|
+
panX += dx; panY += dy;
|
|
140
|
+
lastDrag = { x: e.clientX, y: e.clientY };
|
|
141
|
+
applyStageTransform();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
const dropPtr = e => {
|
|
146
|
+
ptrs.delete(e.pointerId);
|
|
147
|
+
if (ptrs.size < 2) lastDist = null;
|
|
148
|
+
if (ptrs.size === 0) lastDrag = null;
|
|
149
|
+
};
|
|
150
|
+
viewportEl.addEventListener('pointerup', dropPtr);
|
|
151
|
+
viewportEl.addEventListener('pointercancel', dropPtr);
|
|
152
|
+
window.addEventListener('resize', resetMobileFit);
|
|
153
|
+
resetMobileFit();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const applyTheme = theme => {
|
|
157
|
+
if (modalLocked()) return;
|
|
158
|
+
try { localStorage.setItem('clado-theme', theme); } catch {}
|
|
159
|
+
setDesign({ theme });
|
|
160
|
+
post('theme', { theme });
|
|
161
|
+
};
|
|
162
|
+
const captureShot = screenshot && settings['clado.brand']?.showScreenshot !== false ? (async () => {
|
|
163
|
+
try { await screenshot.download(await screenshot.capture({}, readScreenshotCanvas)); }
|
|
164
|
+
catch (error) { directory.showMessage('截图失败', error.message); }
|
|
165
|
+
}) : null;
|
|
166
|
+
|
|
167
|
+
const brand = ui.mountBrand(host, {
|
|
168
|
+
workspaceName: config.workspaceName || 'clado',
|
|
169
|
+
openLobby: config.canSwitchWorkspace && !offline ? () => openLobby() : null,
|
|
170
|
+
openSettings: !offline && config.agent ? () => window.CladoVNext?.openSettings?.('extensions') : null,
|
|
171
|
+
setTheme: applyTheme,
|
|
172
|
+
capture: captureShot,
|
|
107
173
|
});
|
|
108
174
|
const updateControls = ui.mountViewControls(host, {
|
|
109
175
|
setMode: next => {
|
|
@@ -115,6 +181,7 @@
|
|
|
115
181
|
},
|
|
116
182
|
clearFocus: () => frame.contentWindow.CladoRuntime?.clearFocus(),
|
|
117
183
|
showDiagnostics: () => frame.contentWindow.CladoCanvasControls?.showDiagnostics(),
|
|
184
|
+
openHandoff: !offline && config.agent ? () => window.CladoVNext?.openHandoff?.() : null,
|
|
118
185
|
});
|
|
119
186
|
const directory = window.CladoDirectoryPlugin(host, {
|
|
120
187
|
showFilename: settings['clado.directory']?.showFilename !== false,
|
|
@@ -122,8 +189,10 @@
|
|
|
122
189
|
openFromCapability,
|
|
123
190
|
workspaceUrl,
|
|
124
191
|
switchWorkspace: id => { location.href = workspaceUrl(id); },
|
|
125
|
-
openWorkspacePicker: config.canSwitchWorkspace && !offline ? () =>
|
|
192
|
+
openWorkspacePicker: config.canSwitchWorkspace && !offline ? () => openLobby() : null,
|
|
126
193
|
createCanvas: config.canSwitchWorkspace && !offline ? () => createCanvasFlow() : null,
|
|
194
|
+
renameCanvas: config.canSwitchWorkspace && !offline ? doc => renameCanvasFlow(doc) : null,
|
|
195
|
+
deleteCanvas: config.canSwitchWorkspace && !offline ? doc => deleteCanvasFlow(doc) : null,
|
|
127
196
|
refresh: () => scan(true),
|
|
128
197
|
back: () => {
|
|
129
198
|
if (modalLocked()) return;
|
|
@@ -168,6 +237,50 @@
|
|
|
168
237
|
}
|
|
169
238
|
}
|
|
170
239
|
|
|
240
|
+
async function renameCanvasFlow(doc) {
|
|
241
|
+
if (!config.canSwitchWorkspace || offline || !doc?.file) return;
|
|
242
|
+
const nextName = window.prompt('重命名画布文件(保留 .md):', doc.file);
|
|
243
|
+
if (!nextName || !nextName.trim() || nextName.trim() === doc.file) return;
|
|
244
|
+
try {
|
|
245
|
+
const res = await fetch(withWorkspace('/library/fs-workspaces'), {
|
|
246
|
+
method: 'POST',
|
|
247
|
+
headers: { 'content-type': 'application/json' },
|
|
248
|
+
body: JSON.stringify({ action: 'rename_canvas', oldFile: doc.file, newFile: nextName.trim() }),
|
|
249
|
+
});
|
|
250
|
+
const data = await res.json();
|
|
251
|
+
if (!res.ok) throw new Error(data.error || '重命名画布失败');
|
|
252
|
+
if (selected === doc.file) {
|
|
253
|
+
selected = '';
|
|
254
|
+
pendingOpen = data.file;
|
|
255
|
+
}
|
|
256
|
+
await scan(true);
|
|
257
|
+
} catch (err) {
|
|
258
|
+
directory.showMessage('重命名画布失败', err.message || '请稍后重试');
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
async function deleteCanvasFlow(doc) {
|
|
263
|
+
if (!config.canSwitchWorkspace || offline || !doc?.file) return;
|
|
264
|
+
if (!window.confirm(`确定要永久删除画布「${doc.title || doc.file}」(${doc.file}) 吗?`)) return;
|
|
265
|
+
try {
|
|
266
|
+
const res = await fetch(withWorkspace('/library/fs-workspaces'), {
|
|
267
|
+
method: 'POST',
|
|
268
|
+
headers: { 'content-type': 'application/json' },
|
|
269
|
+
body: JSON.stringify({ action: 'delete_canvas', file: doc.file }),
|
|
270
|
+
});
|
|
271
|
+
const data = await res.json();
|
|
272
|
+
if (!res.ok) throw new Error(data.error || '删除画布失败');
|
|
273
|
+
if (selected === doc.file) {
|
|
274
|
+
selected = '';
|
|
275
|
+
version = '';
|
|
276
|
+
saveView();
|
|
277
|
+
}
|
|
278
|
+
await scan(true);
|
|
279
|
+
} catch (err) {
|
|
280
|
+
directory.showMessage('删除画布失败', err.message || '请稍后重试');
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
171
284
|
async function applyWorkspaceSwitch(targetPath, { createIfMissing = false, initStarterCanvas = false } = {}) {
|
|
172
285
|
if (!targetPath || !targetPath.trim()) return;
|
|
173
286
|
const res = await fetch('/library/fs-workspaces', {
|
|
@@ -186,65 +299,59 @@
|
|
|
186
299
|
location.href = '/';
|
|
187
300
|
}
|
|
188
301
|
|
|
302
|
+
const escHtml = s => String(s ?? '').replace(/[&<>"']/g, m => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[m]));
|
|
303
|
+
const lobbyEl = document.getElementById?.('clado-lobby') || null;
|
|
304
|
+
let lobbySearchQuery = '';
|
|
305
|
+
let cachedHubData = null;
|
|
306
|
+
|
|
189
307
|
function ensureWorkspacePicker() {
|
|
190
|
-
if (wsPickerOverlay || !
|
|
308
|
+
if (wsPickerOverlay || !stageEl) return wsPickerOverlay;
|
|
191
309
|
wsPickerOverlay = document.createElement('div');
|
|
192
310
|
wsPickerOverlay.id = 'clado-workspace-picker';
|
|
193
|
-
wsPickerOverlay.className = 'clado-
|
|
311
|
+
wsPickerOverlay.className = 'clado-vnext-mask';
|
|
312
|
+
wsPickerOverlay.hidden = true;
|
|
194
313
|
wsPickerOverlay.innerHTML = `
|
|
195
|
-
<div class="clado-
|
|
196
|
-
<div
|
|
314
|
+
<div class="clado-folder-sheet">
|
|
315
|
+
<div style="display:flex;align-items:center;justify-content:space-between;gap:8px;">
|
|
197
316
|
<div>
|
|
198
|
-
<
|
|
199
|
-
<div data-ws-cur style="font-size:
|
|
317
|
+
<div style="font-size:15.5px;font-weight:630;">打开本地目录或新建工作区</div>
|
|
318
|
+
<div data-ws-cur style="font-size:11.5px;color:var(--clado-ui-muted);margin-top:2px;font-family:ui-monospace,monospace;"></div>
|
|
200
319
|
</div>
|
|
201
|
-
<button type="button" class="clado-
|
|
202
|
-
</div>
|
|
203
|
-
|
|
204
|
-
<div class="clado-market-well" data-ws-recents-wrap style="padding:11px 12px;display:none;flex-direction:column;gap:5px;">
|
|
205
|
-
<div style="font-size:11px;font-weight:650;color:var(--clado-ui-muted);">最近打开的项目</div>
|
|
206
|
-
<div data-ws-recents style="display:flex;flex-direction:column;gap:3px;"></div>
|
|
320
|
+
<button type="button" class="clado-ui-button" data-ws-close style="border-color:var(--clado-ui-well-border);background:var(--clado-ui-well);">关闭</button>
|
|
207
321
|
</div>
|
|
208
322
|
|
|
209
|
-
<div class="clado-
|
|
323
|
+
<div class="clado-well-box" style="padding:11px 12px;display:flex;flex-direction:column;gap:8px;">
|
|
210
324
|
<div style="display:flex;align-items:center;justify-content:space-between;gap:6px;">
|
|
211
|
-
<span style="font-size:11.5px;font-weight:
|
|
212
|
-
<div style="display:flex;gap:
|
|
213
|
-
<button type="button" class="clado-
|
|
214
|
-
<button type="button" class="clado-
|
|
325
|
+
<span style="font-size:11.5px;font-weight:610;color:var(--clado-ui-muted);">浏览本机文件夹</span>
|
|
326
|
+
<div style="display:flex;gap:5px;">
|
|
327
|
+
<button type="button" class="clado-ui-button" data-ws-up style="min-height:26px;font-size:11.5px;padding:3px 9px;border-color:var(--clado-ui-well-border);background:var(--clado-ui-well);">上级</button>
|
|
328
|
+
<button type="button" class="clado-ui-button" data-ws-home style="min-height:26px;font-size:11.5px;padding:3px 9px;border-color:var(--clado-ui-well-border);background:var(--clado-ui-well);">主目录</button>
|
|
215
329
|
</div>
|
|
216
330
|
</div>
|
|
217
|
-
<div data-ws-browse-list style="max-height:
|
|
331
|
+
<div data-ws-browse-list style="max-height:210px;overflow-y:auto;display:flex;flex-direction:column;gap:2px;"></div>
|
|
218
332
|
</div>
|
|
219
333
|
|
|
220
|
-
<div class="clado-
|
|
221
|
-
<div style="font-size:11.5px;color:var(--clado-ui-muted);"
|
|
334
|
+
<div class="clado-well-box" style="padding:12px;display:flex;flex-direction:column;gap:8px;">
|
|
335
|
+
<div style="font-size:11.5px;color:var(--clado-ui-muted);">输入或选择项目路径(若目录不存在将自动新建)</div>
|
|
222
336
|
<div style="display:flex;gap:6px;">
|
|
223
|
-
<input type="text"
|
|
224
|
-
<button type="button" class="clado-
|
|
337
|
+
<input type="text" class="clado-field" data-ws-input placeholder="/path/to/your-project" />
|
|
338
|
+
<button type="button" class="clado-ui-button" data-ws-go style="border-color:var(--clado-ui-well-border);background:var(--clado-ui-well);">定位</button>
|
|
225
339
|
</div>
|
|
226
|
-
<div data-ws-err style="font-size:11.5px;color:#
|
|
227
|
-
<div style="display:flex;gap:8px;
|
|
228
|
-
<button type="button" class="clado-
|
|
229
|
-
<button type="button" data-ws-init style="flex:1.2;
|
|
340
|
+
<div data-ws-err style="font-size:11.5px;color:#be123c;display:none;"></div>
|
|
341
|
+
<div style="display:flex;gap:8px;margin-top:2px;">
|
|
342
|
+
<button type="button" class="clado-ui-button" data-ws-open style="flex:1;border-color:var(--clado-ui-well-border);background:var(--clado-ui-well);">打开此目录</button>
|
|
343
|
+
<button type="button" class="clado-ui-button clado-ui-button-primary" data-ws-init style="flex:1.2;">打开并新建首张画布</button>
|
|
230
344
|
</div>
|
|
231
345
|
</div>
|
|
232
346
|
</div>`;
|
|
233
|
-
|
|
347
|
+
stageEl.append(wsPickerOverlay);
|
|
234
348
|
|
|
235
|
-
let parentDir = '';
|
|
236
|
-
let homeDir = '';
|
|
349
|
+
let parentDir = '', homeDir = '';
|
|
237
350
|
const curEl = wsPickerOverlay.querySelector('[data-ws-cur]');
|
|
238
|
-
const recentsWrap = wsPickerOverlay.querySelector('[data-ws-recents-wrap]');
|
|
239
|
-
const recentsList = wsPickerOverlay.querySelector('[data-ws-recents]');
|
|
240
351
|
const browseList = wsPickerOverlay.querySelector('[data-ws-browse-list]');
|
|
241
352
|
const pathInput = wsPickerOverlay.querySelector('[data-ws-input]');
|
|
242
353
|
const errEl = wsPickerOverlay.querySelector('[data-ws-err]');
|
|
243
|
-
|
|
244
|
-
const showErr = msg => {
|
|
245
|
-
errEl.textContent = msg || '';
|
|
246
|
-
errEl.style.display = msg ? 'block' : 'none';
|
|
247
|
-
};
|
|
354
|
+
const showErr = msg => { errEl.textContent = msg || ''; errEl.style.display = msg ? 'block' : 'none'; };
|
|
248
355
|
|
|
249
356
|
const loadDir = async (dir = '') => {
|
|
250
357
|
showErr('');
|
|
@@ -253,69 +360,43 @@
|
|
|
253
360
|
const res = await fetch('/library/fs-workspaces' + qs, { cache: 'no-store' });
|
|
254
361
|
const data = await res.json();
|
|
255
362
|
if (!res.ok) throw new Error(data.error || '读取目录失败');
|
|
363
|
+
cachedHubData = data;
|
|
256
364
|
parentDir = data.parentDir || '';
|
|
257
365
|
homeDir = data.homeDir || '';
|
|
258
|
-
curEl.textContent = data.
|
|
366
|
+
curEl.textContent = data.currentDir || data.currentWorkspace || '';
|
|
259
367
|
pathInput.value = data.currentDir || data.currentWorkspace || '';
|
|
260
368
|
|
|
261
|
-
const recents = Array.isArray(data.recentWorkspaces) ? data.recentWorkspaces : [];
|
|
262
|
-
if (recents.length) {
|
|
263
|
-
recentsWrap.style.display = 'flex';
|
|
264
|
-
recentsList.replaceChildren();
|
|
265
|
-
for (const r of recents.slice(0, 5)) {
|
|
266
|
-
const row = document.createElement('button');
|
|
267
|
-
row.type = 'button';
|
|
268
|
-
row.className = 'clado-folder-row';
|
|
269
|
-
row.innerHTML = `<span style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"><strong>${r.name}</strong> <small style="color:var(--clado-ui-muted);">${r.path}</small></span><span style="font-size:11px;color:var(--clado-ui-brand);flex:none;">${r.documents ?? 0} 画布</span>`;
|
|
270
|
-
row.onclick = () => applyWorkspaceSwitch(r.path, { createIfMissing: false }).catch(e => showErr(e.message));
|
|
271
|
-
recentsList.append(row);
|
|
272
|
-
}
|
|
273
|
-
} else {
|
|
274
|
-
recentsWrap.style.display = 'none';
|
|
275
|
-
}
|
|
276
|
-
|
|
277
369
|
browseList.replaceChildren();
|
|
278
370
|
const entries = Array.isArray(data.entries) ? data.entries : [];
|
|
279
371
|
if (!entries.length) {
|
|
280
372
|
const empty = document.createElement('div');
|
|
281
|
-
empty.style.cssText = 'padding:
|
|
282
|
-
empty.textContent = '
|
|
373
|
+
empty.style.cssText = 'padding:14px;text-align:center;color:var(--clado-ui-muted);font-size:12px;';
|
|
374
|
+
empty.textContent = '当前目录下无子文件夹,可直接打开此目录或输入新目录名。';
|
|
283
375
|
browseList.append(empty);
|
|
284
376
|
} else {
|
|
285
377
|
for (const item of entries) {
|
|
286
378
|
const row = document.createElement('button');
|
|
287
379
|
row.type = 'button';
|
|
288
380
|
row.className = 'clado-folder-row';
|
|
289
|
-
row.dataset.folderPath = item.path;
|
|
290
381
|
const badges = [
|
|
291
|
-
item.hasClado ? '<span
|
|
292
|
-
item.isGit ? '<span
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
row.innerHTML = `<span style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">📁 ${item.name}</span><small style="color:var(--clado-ui-subtle);flex:none;">${badges || '进入 ›'}</small>`;
|
|
382
|
+
item.hasClado ? '<span class="clado-chip clado-chip-sky">Clado</span>' : '',
|
|
383
|
+
item.isGit ? '<span class="clado-chip clado-chip-neutral">Git</span>' : '',
|
|
384
|
+
].filter(Boolean).join(' ');
|
|
385
|
+
row.innerHTML = `<span style="display:inline-flex;align-items:center;gap:7px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"><svg class="clado-svg-ico" style="color:var(--clado-ui-muted)" viewBox="0 0 24 24"><path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/></svg>${escHtml(item.name)}</span><span style="display:inline-flex;gap:4px;flex:none;">${badges}</span>`;
|
|
296
386
|
row.onclick = () => loadDir(item.path);
|
|
297
387
|
browseList.append(row);
|
|
298
388
|
}
|
|
299
389
|
}
|
|
300
|
-
} catch (err) {
|
|
301
|
-
showErr(err.message || '读取目录失败');
|
|
302
|
-
}
|
|
390
|
+
} catch (err) { showErr(err.message || '读取目录失败'); }
|
|
303
391
|
};
|
|
304
392
|
|
|
305
393
|
wsPickerOverlay.addEventListener('click', ev => {
|
|
306
|
-
if (ev.target === wsPickerOverlay || ev.target.closest('[data-ws-close]'))
|
|
307
|
-
wsPickerOverlay.classList.remove('show');
|
|
308
|
-
}
|
|
394
|
+
if (ev.target === wsPickerOverlay || ev.target.closest('[data-ws-close]')) wsPickerOverlay.hidden = true;
|
|
309
395
|
});
|
|
310
396
|
pathInput.addEventListener('keydown', ev => {
|
|
311
|
-
if (ev.key === 'Enter') {
|
|
312
|
-
ev.preventDefault();
|
|
313
|
-
if (pathInput.value.trim()) loadDir(pathInput.value.trim());
|
|
314
|
-
}
|
|
397
|
+
if (ev.key === 'Enter') { ev.preventDefault(); if (pathInput.value.trim()) loadDir(pathInput.value.trim()); }
|
|
315
398
|
});
|
|
316
|
-
wsPickerOverlay.querySelector('[data-ws-go]').onclick = () => {
|
|
317
|
-
if (pathInput.value.trim()) loadDir(pathInput.value.trim());
|
|
318
|
-
};
|
|
399
|
+
wsPickerOverlay.querySelector('[data-ws-go]').onclick = () => { if (pathInput.value.trim()) loadDir(pathInput.value.trim()); };
|
|
319
400
|
wsPickerOverlay.querySelector('[data-ws-up]').onclick = () => { if (parentDir) loadDir(parentDir); };
|
|
320
401
|
wsPickerOverlay.querySelector('[data-ws-home]').onclick = () => { if (homeDir) loadDir(homeDir); };
|
|
321
402
|
wsPickerOverlay.querySelector('[data-ws-open]').onclick = () => {
|
|
@@ -329,52 +410,240 @@
|
|
|
329
410
|
}
|
|
330
411
|
|
|
331
412
|
function openWorkspacePicker(initialDir = '') {
|
|
332
|
-
if (!config.canSwitchWorkspace || offline
|
|
413
|
+
if (!config.canSwitchWorkspace || offline) return;
|
|
333
414
|
const modal = ensureWorkspacePicker();
|
|
334
415
|
if (!modal) return;
|
|
335
|
-
modal.
|
|
416
|
+
modal.hidden = false;
|
|
336
417
|
modal._loadDir(initialDir);
|
|
337
418
|
}
|
|
338
419
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
420
|
+
function closeLobby() {
|
|
421
|
+
if (lobbyEl) lobbyEl.hidden = true;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
function renderLobbyView(hubData) {
|
|
425
|
+
if (!lobbyEl) return;
|
|
426
|
+
const meta = window.CladoVNext?.getMeta?.() || {};
|
|
427
|
+
const recents = Array.isArray(hubData?.recentWorkspaces) ? hubData.recentWorkspaces : [];
|
|
428
|
+
const currentInRecents = recents.some(r => r.path === hubData?.currentWorkspace);
|
|
429
|
+
const allWorkspaces = [...recents];
|
|
430
|
+
if (!config.hubMode && hubData?.currentWorkspace && !currentInRecents) {
|
|
431
|
+
allWorkspaces.unshift({
|
|
432
|
+
path: hubData.currentWorkspace,
|
|
433
|
+
name: hubData.currentName || config.workspaceName || '当前项目',
|
|
434
|
+
gitBranch: hubData.currentProfile?.gitBranch || '',
|
|
435
|
+
codeFiles: hubData.currentProfile?.codeFiles || 0,
|
|
436
|
+
primaryLang: hubData.currentProfile?.primaryLang || '',
|
|
437
|
+
documents: index.documents.length,
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
const q = lobbySearchQuery.trim().toLowerCase();
|
|
441
|
+
const filtered = allWorkspaces.filter(w => !q || (w.name + ' ' + w.path).toLowerCase().includes(q));
|
|
442
|
+
const eco = meta.ecosystem || {};
|
|
443
|
+
const extCount = (eco.packages?.length || 0) + (eco.skills?.length || 0) + 1;
|
|
444
|
+
const mcpCount = eco.mcpServers?.length || 0;
|
|
445
|
+
const roleCount = meta.roles?.length || 4;
|
|
446
|
+
const activeModel = meta.activeModelLabel || '点击设置模型';
|
|
447
|
+
|
|
448
|
+
lobbyEl.innerHTML = `
|
|
449
|
+
<div class="clado-lobby-inner">
|
|
450
|
+
<header class="clado-lobby-head">
|
|
451
|
+
<div style="display:flex;align-items:center;gap:13px;">
|
|
452
|
+
<div class="clado-brand-gem">
|
|
453
|
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.1" stroke-linecap="round">
|
|
454
|
+
<path d="M17 7.5A6.5 6.5 0 1 0 17 16.5"/>
|
|
455
|
+
<circle cx="17.5" cy="12" r="1.4" fill="currentColor" stroke="none"/>
|
|
456
|
+
</svg>
|
|
457
|
+
</div>
|
|
351
458
|
<div>
|
|
352
|
-
<div style="
|
|
353
|
-
|
|
459
|
+
<div style="display:flex;align-items:center;gap:8px;">
|
|
460
|
+
<span style="font-size:19px;font-weight:640;letter-spacing:-0.02em;">clado</span>
|
|
461
|
+
<span class="clado-chip clado-chip-sky">Pi Engine</span>
|
|
462
|
+
</div>
|
|
463
|
+
<div style="font-size:12px;color:var(--clado-ui-muted);margin-top:2px;">空间画布设计 · 多角色编排 · 代码与测试交付</div>
|
|
464
|
+
</div>
|
|
465
|
+
</div>
|
|
466
|
+
|
|
467
|
+
<div style="display:flex;align-items:center;gap:10px;">
|
|
468
|
+
<div class="clado-ui-glass" style="display:flex;align-items:center;gap:8px;padding:7px 14px;border-radius:999px;width:230px;">
|
|
469
|
+
<svg class="clado-svg-ico" style="color:var(--clado-ui-subtle)" viewBox="0 0 24 24"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>
|
|
470
|
+
<input type="text" data-lobby-search value="${escHtml(lobbySearchQuery)}" placeholder="搜索项目工作区…" style="border:0;outline:0;background:transparent;width:100%;font-size:12.5px;color:var(--clado-ui-text);" />
|
|
354
471
|
</div>
|
|
355
|
-
<div class="clado-
|
|
356
|
-
<
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
<button type="button" class="clado-launchpad-btn" data-lp-new-canvas>
|
|
361
|
-
<span><strong>✨ 在当前工作区新建首张画布</strong><br/><small style="color:var(--clado-ui-muted);">立即创建初始架构画布进入三视图协作</small></span>
|
|
362
|
-
<span style="opacity:.5;">+</span>
|
|
363
|
-
</button>
|
|
364
|
-
<button type="button" class="clado-launchpad-btn" data-lp-llm>
|
|
365
|
-
<span><strong>⚙ 配置供应商与主力模型</strong><br/><small style="color:var(--clado-ui-muted);">支持 OpenAI / Anthropic / DeepSeek / OpenRouter / Ollama</small></span>
|
|
366
|
-
<span style="opacity:.5;">›</span>
|
|
367
|
-
</button>
|
|
472
|
+
<div class="clado-ui-glass" style="display:flex;align-items:center;gap:8px;padding:5px 7px 5px 13px;border-radius:999px;">
|
|
473
|
+
<span class="clado-dot-ok"></span>
|
|
474
|
+
<span style="font-family:ui-monospace,monospace;font-size:11.5px;color:var(--clado-ui-text-soft);">${escHtml(activeModel)}</span>
|
|
475
|
+
<span class="clado-top-pill-sep"></span>
|
|
476
|
+
<button type="button" class="clado-ui-button" data-lobby-settings style="min-height:28px;padding:4px 10px;font-size:12px;">设置</button>
|
|
368
477
|
</div>
|
|
369
478
|
</div>
|
|
370
|
-
</
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
479
|
+
</header>
|
|
480
|
+
|
|
481
|
+
<div style="display:flex;align-items:flex-end;justify-content:space-between;gap:14px;">
|
|
482
|
+
<div>
|
|
483
|
+
<div style="font-size:24px;font-weight:640;letter-spacing:-0.025em;">工作区</div>
|
|
484
|
+
<div style="font-size:13px;color:var(--clado-ui-muted);margin-top:5px;">选择已有项目进入空间画布,或打开本地代码仓库一键梳理架构。</div>
|
|
485
|
+
</div>
|
|
486
|
+
<div style="display:flex;align-items:center;gap:10px;">
|
|
487
|
+
${!config.hubMode ? '<button type="button" class="clado-ui-button" data-lobby-back style="border-color:var(--clado-ui-well-border);background:var(--clado-ui-well);padding:8px 14px;border-radius:13px;">返回当前画布</button>' : ''}
|
|
488
|
+
<button type="button" class="clado-ui-button" data-lobby-open style="border-color:var(--clado-ui-well-border);background:var(--clado-ui-well);padding:8px 15px;border-radius:13px;">打开本地目录</button>
|
|
489
|
+
<button type="button" class="clado-ui-button clado-ui-button-primary" data-lobby-new style="padding:8px 16px;border-radius:13px;">+ 新建工作区</button>
|
|
490
|
+
</div>
|
|
491
|
+
</div>
|
|
492
|
+
|
|
493
|
+
<div class="clado-lobby-grid" data-lobby-cards></div>
|
|
494
|
+
|
|
495
|
+
<div class="clado-ui-glass" style="margin-top:26px;border-radius:18px;padding:13px 20px;display:flex;align-items:center;justify-content:space-between;font-size:12.5px;">
|
|
496
|
+
<div style="display:flex;align-items:center;gap:14px;">
|
|
497
|
+
<span style="display:inline-flex;align-items:center;gap:7px;font-weight:540;color:var(--clado-ui-text-soft);"><span class="clado-dot-ok"></span>Pi 1.0 运行时就绪</span>
|
|
498
|
+
<span style="font-family:ui-monospace,monospace;font-size:11.5px;color:var(--clado-ui-subtle);">${escHtml(meta.agentDir || '~/.pi/agent')}</span>
|
|
499
|
+
<span class="clado-top-pill-sep"></span>
|
|
500
|
+
<span style="color:var(--clado-ui-muted);">${extCount} 个扩展 · ${mcpCount} 个 MCP · ${roleCount} 套角色</span>
|
|
501
|
+
</div>
|
|
502
|
+
<button type="button" class="clado-ui-button" data-lobby-ext style="min-height:28px;font-size:12px;">管理扩展与能力 →</button>
|
|
503
|
+
</div>
|
|
504
|
+
</div>
|
|
505
|
+
`;
|
|
506
|
+
|
|
507
|
+
const cardsWrap = lobbyEl.querySelector('[data-lobby-cards]');
|
|
508
|
+
if (!filtered.length) {
|
|
509
|
+
cardsWrap.innerHTML = `<div class="clado-well-box" style="grid-column:1/-1;padding:28px;text-align:center;color:var(--clado-ui-muted);">暂无最近工作区,点击右上角「打开本地目录」或「+ 新建工作区」立即开始。</div>`;
|
|
510
|
+
} else {
|
|
511
|
+
for (const w of filtered.slice(0, 9)) {
|
|
512
|
+
const card = document.createElement('button');
|
|
513
|
+
card.type = 'button';
|
|
514
|
+
card.className = 'clado-ws-card';
|
|
515
|
+
const initials = (w.name || 'WS').replace(/[^a-zA-Z0-9\u4e00-\u9fa5]/g, '').slice(0, 2).toUpperCase() || 'WS';
|
|
516
|
+
const needsAnalysis = (w.documents || 0) === 0 && (w.codeFiles || 0) > 0;
|
|
517
|
+
const badgeHtml = needsAnalysis
|
|
518
|
+
? '<span class="clado-chip clado-chip-amber">待分析</span>'
|
|
519
|
+
: w.gitBranch
|
|
520
|
+
? `<span class="clado-chip clado-chip-sky">${escHtml(w.gitBranch)}</span>`
|
|
521
|
+
: '<span class="clado-chip clado-chip-mint">工作区</span>';
|
|
522
|
+
const desc = needsAnalysis
|
|
523
|
+
? `已检测到 ${escHtml(w.primaryLang || '本地')} 源码仓库(${w.codeFiles} 个文件),尚未生成架构画布,可一键分析出图。`
|
|
524
|
+
: (w.documents || 0) > 0
|
|
525
|
+
? `包含 ${w.documents} 张空间画布${w.primaryLang ? ` · ${w.primaryLang} 工程` : ''},可继续梳理架构或交接交付。`
|
|
526
|
+
: '空白工作区,进入后可直接起稿画布或让角色协助拆解设计。';
|
|
527
|
+
card.innerHTML = `
|
|
528
|
+
<div>
|
|
529
|
+
<div style="display:flex;align-items:center;justify-content:space-between;gap:8px;">
|
|
530
|
+
<div style="display:flex;align-items:center;gap:11px;min-width:0;">
|
|
531
|
+
<div class="clado-ws-mono">${escHtml(initials)}</div>
|
|
532
|
+
<div style="min-width:0;">
|
|
533
|
+
<div style="font-size:14.5px;font-weight:620;color:var(--clado-ui-text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${escHtml(w.name)}</div>
|
|
534
|
+
<div style="font-family:ui-monospace,monospace;font-size:11px;color:var(--clado-ui-subtle);margin-top:1px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${escHtml(w.path)}</div>
|
|
535
|
+
</div>
|
|
536
|
+
</div>
|
|
537
|
+
${badgeHtml}
|
|
538
|
+
</div>
|
|
539
|
+
<p style="font-size:12.5px;line-height:1.62;color:var(--clado-ui-muted);margin:15px 0 0;">${desc}</p>
|
|
540
|
+
</div>
|
|
541
|
+
<div style="display:flex;align-items:center;justify-content:space-between;padding-top:13px;border-top:1px solid var(--clado-ui-edge);font-size:12px;">
|
|
542
|
+
<span style="color:var(--clado-ui-subtle);">${w.documents || 0} 张画布</span>
|
|
543
|
+
<span style="font-weight:560;color:var(--clado-ui-text-soft);">${needsAnalysis ? '分析并进入 →' : '进入 →'}</span>
|
|
544
|
+
</div>
|
|
545
|
+
`;
|
|
546
|
+
card.onclick = () => {
|
|
547
|
+
if (w.path === hubData?.currentWorkspace && !config.hubMode) {
|
|
548
|
+
closeLobby();
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
applyWorkspaceSwitch(w.path, { createIfMissing: false }).catch(e => showToast(e.message));
|
|
552
|
+
};
|
|
553
|
+
cardsWrap.append(card);
|
|
554
|
+
}
|
|
377
555
|
}
|
|
556
|
+
|
|
557
|
+
const searchInput = lobbyEl.querySelector('[data-lobby-search]');
|
|
558
|
+
searchInput.addEventListener('input', () => { lobbySearchQuery = searchInput.value; renderLobbyView(hubData); });
|
|
559
|
+
lobbyEl.querySelector('[data-lobby-settings]').onclick = () => window.CladoVNext?.openSettings?.('models');
|
|
560
|
+
lobbyEl.querySelector('[data-lobby-ext]').onclick = () => window.CladoVNext?.openSettings?.('extensions');
|
|
561
|
+
lobbyEl.querySelector('[data-lobby-open]').onclick = () => openWorkspacePicker();
|
|
562
|
+
lobbyEl.querySelector('[data-lobby-new]').onclick = () => openWorkspacePicker();
|
|
563
|
+
const backBtn = lobbyEl.querySelector('[data-lobby-back]');
|
|
564
|
+
if (backBtn) backBtn.onclick = () => closeLobby();
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
async function openLobby() {
|
|
568
|
+
if (!config.canSwitchWorkspace || offline || !lobbyEl) return;
|
|
569
|
+
lobbyEl.hidden = false;
|
|
570
|
+
try {
|
|
571
|
+
const res = await fetch('/library/fs-workspaces', { cache: 'no-store' });
|
|
572
|
+
if (res.ok) cachedHubData = await res.json();
|
|
573
|
+
} catch {}
|
|
574
|
+
renderLobbyView(cachedHubData || {});
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
function renderEmptyOnboarding(profile = {}) {
|
|
578
|
+
const emptyEl = $('#emptyState');
|
|
579
|
+
if (!emptyEl) return;
|
|
580
|
+
let selectedTpl = 'arch';
|
|
581
|
+
const hasCode = (profile.codeFiles || 0) > 0;
|
|
582
|
+
const chipLabel = hasCode
|
|
583
|
+
? `已识别本地仓库 · ${profile.codeFiles} 个 ${profile.primaryLang || '源码'} 文件`
|
|
584
|
+
: `当前工作区 · ${config.workspaceName || '新建项目'}`;
|
|
585
|
+
emptyEl.innerHTML = `
|
|
586
|
+
<div class="clado-empty-card">
|
|
587
|
+
<div class="clado-prism-aura-under"></div>
|
|
588
|
+
<div style="display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;">
|
|
589
|
+
<span class="clado-chip clado-chip-sky" style="padding:4px 11px;"><span class="clado-dot-sky" style="width:6px;height:6px;"></span>${escHtml(chipLabel)}</span>
|
|
590
|
+
<span style="font-family:ui-monospace,monospace;font-size:11.5px;color:var(--clado-ui-subtle);">${escHtml(config.workspacePath || '')}</span>
|
|
591
|
+
</div>
|
|
592
|
+
<div style="font-size:22px;font-weight:630;letter-spacing:-0.02em;margin-top:16px;">想怎样开始这张画布?</div>
|
|
593
|
+
<p style="font-size:13px;color:var(--clado-ui-muted);margin:6px 0 0;line-height:1.6;">
|
|
594
|
+
选择一个分析模板让「主架构师」快速读取源码并生成人可读的架构图,或直接从空白画布自由起稿。
|
|
595
|
+
</p>
|
|
596
|
+
<div class="clado-tpl-grid">
|
|
597
|
+
<button type="button" class="clado-tpl-btn selected" data-tpl="arch">
|
|
598
|
+
<svg class="clado-svg-ico" style="width:17px;height:17px;color:#0284c7;" viewBox="0 0 24 24"><rect x="3" y="3" width="7" height="7" rx="1.5"/><rect x="14" y="3" width="7" height="7" rx="1.5"/><rect x="8.5" y="14" width="7" height="7" rx="1.5"/><path d="M6.5 10v2h11v-2M12 12v2"/></svg>
|
|
599
|
+
<div style="font-size:13.5px;font-weight:610;margin-top:2px;">老代码架构梳理</div>
|
|
600
|
+
<div style="font-size:11.5px;color:var(--clado-ui-muted);line-height:1.55;">扫描模块边界、调用链与核心入口,自动铺出清晰卡片图。</div>
|
|
601
|
+
</button>
|
|
602
|
+
<button type="button" class="clado-tpl-btn" data-tpl="req">
|
|
603
|
+
<svg class="clado-svg-ico" style="width:17px;height:17px;color:#059669;" viewBox="0 0 24 24"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><path d="M14 2v6h6M8 13h8M8 17h5"/></svg>
|
|
604
|
+
<div style="font-size:13.5px;font-weight:610;margin-top:2px;">新需求拆解设计</div>
|
|
605
|
+
<div style="font-size:11.5px;color:var(--clado-ui-muted);line-height:1.55;">把需求拆为数据契约、状态流转与风险清单,边改边定稿。</div>
|
|
606
|
+
</button>
|
|
607
|
+
<button type="button" class="clado-tpl-btn" data-tpl="qa">
|
|
608
|
+
<svg class="clado-svg-ico" style="width:17px;height:17px;color:#7c3aed;" viewBox="0 0 24 24"><path d="M9 11l3 3L22 4"/><path d="M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"/></svg>
|
|
609
|
+
<div style="font-size:13.5px;font-weight:610;margin-top:2px;">测试与压测矩阵</div>
|
|
610
|
+
<div style="font-size:11.5px;color:var(--clado-ui-muted);line-height:1.55;">提炼主链路与异常分支,准备一键交付给测试角色跑通。</div>
|
|
611
|
+
</button>
|
|
612
|
+
</div>
|
|
613
|
+
<div style="display:flex;align-items:center;justify-content:space-between;margin-top:22px;padding-top:18px;border-top:1px solid var(--clado-ui-edge);">
|
|
614
|
+
<button type="button" class="clado-ui-button" data-empty-skip>跳过引导,新建空白画布</button>
|
|
615
|
+
<button type="button" class="clado-ui-button clado-ui-button-primary" data-empty-start style="padding:9px 20px;">开始分析并生成画布 →</button>
|
|
616
|
+
</div>
|
|
617
|
+
</div>
|
|
618
|
+
`;
|
|
619
|
+
emptyEl.querySelectorAll('[data-tpl]').forEach(btn => {
|
|
620
|
+
btn.onclick = () => {
|
|
621
|
+
selectedTpl = btn.dataset.tpl;
|
|
622
|
+
emptyEl.querySelectorAll('[data-tpl]').forEach(b => b.classList.toggle('selected', b === btn));
|
|
623
|
+
};
|
|
624
|
+
});
|
|
625
|
+
emptyEl.querySelector('[data-empty-skip]').onclick = () => createCanvasFlow('系统架构概览');
|
|
626
|
+
emptyEl.querySelector('[data-empty-start]').onclick = () => {
|
|
627
|
+
showToast('主架构师正在分析源码并绘制画布…');
|
|
628
|
+
window.CladoVNext?.startCodeAnalysis?.(selectedTpl);
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
if (config.canSwitchWorkspace && !offline) {
|
|
633
|
+
window.addEventListener('clado:open-workspace-picker', () => openLobby());
|
|
634
|
+
window.addEventListener('clado:meta-updated', () => {
|
|
635
|
+
if (lobbyEl && !lobbyEl.hidden) renderLobbyView(cachedHubData || {});
|
|
636
|
+
});
|
|
637
|
+
renderEmptyOnboarding({});
|
|
638
|
+
fetch('/library/fs-workspaces', { cache: 'no-store' })
|
|
639
|
+
.then(r => r.ok ? r.json() : null)
|
|
640
|
+
.then(data => {
|
|
641
|
+
if (!data) return;
|
|
642
|
+
cachedHubData = data;
|
|
643
|
+
renderEmptyOnboarding(data.currentProfile || {});
|
|
644
|
+
if (config.hubMode) openLobby();
|
|
645
|
+
})
|
|
646
|
+
.catch(() => { if (config.hubMode) openLobby(); });
|
|
378
647
|
}
|
|
379
648
|
const liveObjectsEnabled = Boolean(config.selection && !offline && document.body);
|
|
380
649
|
let canvasObjectsList = [];
|
|
@@ -573,28 +842,30 @@
|
|
|
573
842
|
});
|
|
574
843
|
} else {
|
|
575
844
|
addLabel('画布空白处');
|
|
576
|
-
addItem('
|
|
577
|
-
saveObject({ kind: 'sticky', title: '
|
|
845
|
+
addItem('+ 在此处新建便签', () => {
|
|
846
|
+
saveObject({ kind: 'sticky', title: '设计便签', pluginId: 'starter.sticky-notes', x: detail.wx, y: detail.wy, tint: 'amber', text: '记录一条新想法…' });
|
|
578
847
|
});
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
848
|
+
if (window.CladoVNext?.isComponentEnabled?.('lofi-studio-widget')) {
|
|
849
|
+
addItem('+ 添加 Lo-Fi 专注播放器', () => {
|
|
850
|
+
saveObject({
|
|
851
|
+
kind: 'music',
|
|
852
|
+
title: 'Lo-Fi 专注播放器',
|
|
853
|
+
pluginId: 'starter.lofi-player',
|
|
854
|
+
x: detail.wx,
|
|
855
|
+
y: detail.wy,
|
|
856
|
+
width: 326,
|
|
857
|
+
data: {
|
|
858
|
+
expanded: false,
|
|
859
|
+
selRenderMode: 'custom',
|
|
860
|
+
tracks: [
|
|
861
|
+
{ id: 't1', title: 'Midnight Rain · 深夜雨声', duration: '03:24', liked: true },
|
|
862
|
+
{ id: 't2', title: 'Glass Horizon · 玻璃天际线', duration: '02:58', liked: false },
|
|
863
|
+
{ id: 't3', title: 'Soft Focus · 柔焦白噪音', duration: '04:12', liked: false },
|
|
864
|
+
],
|
|
865
|
+
},
|
|
866
|
+
});
|
|
596
867
|
});
|
|
597
|
-
}
|
|
868
|
+
}
|
|
598
869
|
addSep();
|
|
599
870
|
addItem('居中复位画布', () => frame.contentWindow.CladoPrototype?.fit());
|
|
600
871
|
}
|
|
@@ -617,11 +888,14 @@
|
|
|
617
888
|
selectionBarEl.innerHTML = `
|
|
618
889
|
<span class="clado-selection-dot"></span>
|
|
619
890
|
<span class="clado-selection-text" data-sel-summary>已选 0 项</span>
|
|
620
|
-
<button type="button" class="clado-selection-send" data-sel-
|
|
891
|
+
<button type="button" class="clado-selection-send" data-sel-dev>交给开发落地</button>
|
|
892
|
+
<button type="button" class="clado-selection-secondary" data-sel-qa>生成并跑测试</button>
|
|
621
893
|
<button type="button" class="clado-selection-clear" data-sel-clear>完成</button>`;
|
|
622
|
-
selectionBarEl.querySelector('[data-sel-
|
|
623
|
-
|
|
624
|
-
|
|
894
|
+
selectionBarEl.querySelector('[data-sel-dev]').onclick = () => {
|
|
895
|
+
window.CladoVNext?.triggerHandoff?.('developer');
|
|
896
|
+
};
|
|
897
|
+
selectionBarEl.querySelector('[data-sel-qa]').onclick = () => {
|
|
898
|
+
window.CladoVNext?.triggerHandoff?.('tester');
|
|
625
899
|
};
|
|
626
900
|
selectionBarEl.querySelector('[data-sel-clear]').onclick = () => {
|
|
627
901
|
objectSelection.clear();
|
|
@@ -629,7 +903,7 @@
|
|
|
629
903
|
syncFrameObjects();
|
|
630
904
|
renderSelectionSummary();
|
|
631
905
|
};
|
|
632
|
-
|
|
906
|
+
stageEl.append(selectionBarEl);
|
|
633
907
|
|
|
634
908
|
canvasCtxMenuEl = document.createElement('div');
|
|
635
909
|
canvasCtxMenuEl.id = 'clado-canvas-ctx-menu';
|
|
@@ -681,20 +955,17 @@
|
|
|
681
955
|
}
|
|
682
956
|
}
|
|
683
957
|
if (isEnabled('clado.agent')) window.CladoAgentPlugin(host, {
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
focusTarget,
|
|
690
|
-
readCanvas() {
|
|
958
|
+
withWorkspace,
|
|
959
|
+
setTheme: applyTheme,
|
|
960
|
+
capture: captureShot,
|
|
961
|
+
focusCanvas: (file, heading) => focusTarget(file, heading ? [heading] : null, heading || ''),
|
|
962
|
+
readContext() {
|
|
691
963
|
const objSel = objectSelection.size ? [...objectSelection.values()] : undefined;
|
|
692
|
-
if (readyCanvas?.frame !== frame) return objSel ? { objectSelection: objSel } :
|
|
964
|
+
if (readyCanvas?.frame !== frame) return { file: selected || '', selection: [], ...(objSel ? { objectSelection: objSel } : {}) };
|
|
693
965
|
const { file, revision } = readyCanvas;
|
|
694
966
|
const selection = aiSelection?.file === file && aiSelection.version === revision ? aiSelection.nodes : [];
|
|
695
967
|
return { file, revision, selection, ...(objSel ? { objectSelection: objSel } : {}) };
|
|
696
968
|
},
|
|
697
|
-
viewId: capabilities?.viewId,
|
|
698
969
|
});
|
|
699
970
|
if (!['light', 'dark'].includes(design.theme)) design.theme = 'light';
|
|
700
971
|
try { const savedTheme = localStorage.getItem('clado-theme'); if (['light', 'dark'].includes(savedTheme)) design.theme = savedTheme; } catch {}
|