cladogram 0.5.4 → 0.5.5-beta.2
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 +8 -6
- package/bin/clado.js +5 -5
- package/docs/release.md +13 -0
- package/package.json +1 -1
- package/plugins/agent/index.js +458 -25
- package/plugins/agent/style.css +299 -8
- package/plugins/directory/capabilities.json +1 -1
- package/plugins/directory/index.js +57 -2
- package/plugins/directory/style.css +11 -0
- package/plugins/view-controls/index.js +1 -1
- package/plugins/view-controls/style.css +30 -10
- package/skills/clado/SKILL.md +17 -16
- package/src/agent/executors.js +213 -0
- package/src/agent/probe.js +176 -0
- package/src/agent/providers/anthropic.js +220 -0
- package/src/agent/providers/index.js +52 -0
- package/src/agent/providers/openai.js +146 -0
- package/src/agent/runtime.js +557 -0
- package/src/agent/sessions.js +129 -0
- package/src/html/app-css.js +62 -9
- package/src/html/canvas-chain.js +2 -1
- package/src/html/canvas-ui.css +63 -0
- package/src/html/page.js +4 -0
- package/src/html/plugin-ui.css +12 -0
- package/src/html/plugin-ui.js +8 -2
- package/src/html/runtime-api.js +136 -5
- package/src/html/runtime.js +160 -290
- package/src/html/view-registry.js +95 -0
- package/src/html/views/view-cards.js +28 -0
- package/src/html/views/view-doc.js +51 -0
- package/src/html/views/view-mindmap.js +173 -0
- package/src/server/agent.js +335 -17
- package/src/server/assets/library-canvas.js +13 -3
- package/src/server/assets/library-plugin-bridge.js +2 -2
- package/src/server/assets/library-plugins.js +2 -2
- package/src/server/assets/library.css +5 -0
- package/src/server/assets/library.html +1 -1
- package/src/server/assets/library.js +157 -20
- package/src/server/events.js +189 -0
- package/src/server/export.js +1 -1
- package/src/server/mcp.js +16 -16
- package/src/server/plugin-capabilities.js +38 -22
- package/src/server/plugin-settings.js +27 -1
- package/src/server/plugins.js +17 -4
- package/src/server/workspace.js +171 -56
- package/src/skill/install.js +1 -1
- package/src/skill/targets.js +3 -3
- package/src/util/update.js +3 -2
- package/src/workspace/service.js +23 -15
- package/src/workspace/storage.js +88 -20
- package/templates/business-flow.mdc +1 -1
- package/templates/call-chain.mdc +1 -1
- package/templates/data-design.mdc +1 -1
- package/templates/test-cases.mdc +47 -0
package/src/html/app-css.js
CHANGED
|
@@ -287,9 +287,31 @@ body.dragging, body.dragging *{user-select:none; -webkit-user-select:none}
|
|
|
287
287
|
.zoomable.zcode pre{margin:0 !important}
|
|
288
288
|
.zoomable.zcode:hover pre{border-color:var(--accent)}
|
|
289
289
|
#lensInner .markdown-body{background:transparent}
|
|
290
|
-
#lensInner .markdown-body pre{
|
|
291
|
-
|
|
292
|
-
|
|
290
|
+
#lensInner .markdown-body pre{
|
|
291
|
+
margin:0 !important; padding:2px 4px !important;
|
|
292
|
+
background:transparent !important; border:0 !important; box-shadow:none !important;
|
|
293
|
+
white-space:pre; font-size:13px; line-height:1.65;
|
|
294
|
+
}
|
|
295
|
+
#lensInner .markdown-body pre code{background:transparent !important; padding:0 !important}
|
|
296
|
+
#lensInner .markdown-body table{
|
|
297
|
+
font-size:14px; width:auto; display:table; margin:0;
|
|
298
|
+
border-collapse:separate; border-spacing:0;
|
|
299
|
+
border-radius:10px; overflow:hidden;
|
|
300
|
+
border:1px solid color-mix(in srgb, var(--line) 75%, transparent);
|
|
301
|
+
background:color-mix(in srgb, var(--panel) 55%, transparent);
|
|
302
|
+
}
|
|
303
|
+
#lensInner .markdown-body table th,#lensInner .markdown-body table td{
|
|
304
|
+
padding:8px 14px !important;
|
|
305
|
+
border:0 !important;
|
|
306
|
+
border-right:1px solid color-mix(in srgb, var(--line) 65%, transparent) !important;
|
|
307
|
+
border-bottom:1px solid color-mix(in srgb, var(--line) 65%, transparent) !important;
|
|
308
|
+
white-space:nowrap;
|
|
309
|
+
}
|
|
310
|
+
#lensInner .markdown-body table tr > :last-child{border-right:0 !important}
|
|
311
|
+
#lensInner .markdown-body table tr:last-child > td{border-bottom:0 !important}
|
|
312
|
+
#lensInner .markdown-body table th{
|
|
313
|
+
background:color-mix(in srgb, var(--bg) 70%, transparent);
|
|
314
|
+
}
|
|
293
315
|
|
|
294
316
|
/* ── 文档模式 ───────────────────────────────────────────── */
|
|
295
317
|
#doc{position:absolute; inset:0; display:none; overflow:auto; background:var(--panel)}
|
|
@@ -349,23 +371,54 @@ body.dragging, body.dragging *{user-select:none; -webkit-user-select:none}
|
|
|
349
371
|
#mwires path{fill:none; stroke:var(--accent); stroke-width:1.7; stroke-opacity:.7}
|
|
350
372
|
#mwires path.edge{stroke-opacity:.45; stroke-width:1.4; stroke-dasharray:5 4}
|
|
351
373
|
|
|
352
|
-
/* ──
|
|
353
|
-
#lens{
|
|
354
|
-
|
|
374
|
+
/* ── 放大镜:代码 / Mermaid / 表格统一无外边框玻璃质感 + 快速渐变 ─────── */
|
|
375
|
+
#lens{
|
|
376
|
+
position:fixed; inset:0; z-index:80;
|
|
377
|
+
display:block; opacity:0; visibility:hidden; pointer-events:none;
|
|
378
|
+
background:color-mix(in srgb, var(--bg) 36%, transparent);
|
|
379
|
+
backdrop-filter:blur(4px);
|
|
380
|
+
transition:opacity 160ms ease, visibility 0s linear 160ms;
|
|
381
|
+
}
|
|
382
|
+
#lens.open{
|
|
383
|
+
opacity:1; visibility:visible; pointer-events:auto;
|
|
384
|
+
transition:opacity 160ms ease, visibility 0s;
|
|
385
|
+
}
|
|
355
386
|
.lensbar{
|
|
356
|
-
position:absolute; top:14px; left:50%; transform:
|
|
387
|
+
position:absolute; top:14px; left:50%; transform:translate(-50%, -6px); z-index:2;
|
|
357
388
|
display:flex; align-items:center; gap:8px; padding:6px 8px 6px 14px;
|
|
358
389
|
font-size:12px;
|
|
390
|
+
transition:transform 160ms ease;
|
|
359
391
|
}
|
|
392
|
+
#lens.open .lensbar{transform:translate(-50%, 0)}
|
|
360
393
|
.lensbar button{
|
|
361
394
|
width:28px; min-height:26px; padding:0; border-radius:7px; font-size:14px;
|
|
362
395
|
}
|
|
363
|
-
#lensStage{
|
|
396
|
+
#lensStage{
|
|
397
|
+
position:absolute; inset:0; overflow:hidden; cursor:grab;
|
|
398
|
+
transform:scale(.985);
|
|
399
|
+
transition:transform 160ms ease;
|
|
400
|
+
}
|
|
401
|
+
#lens.open #lensStage{transform:scale(1)}
|
|
364
402
|
#lensStage.drag{cursor:grabbing}
|
|
365
|
-
#lensInner{
|
|
403
|
+
#lensInner{
|
|
404
|
+
position:absolute; left:0; top:0; transform-origin:0 0; padding:20px 22px;
|
|
405
|
+
border:0 !important;
|
|
406
|
+
border-radius:14px;
|
|
407
|
+
--clado-ui-glass-fill: rgb(252 252 252 / .64);
|
|
408
|
+
--clado-ui-glass-blur: 22px;
|
|
409
|
+
box-shadow:0 12px 40px rgb(18 24 34 / .12);
|
|
410
|
+
}
|
|
411
|
+
[data-theme="dark"] #lensInner{
|
|
412
|
+
--clado-ui-glass-fill: rgb(24 28 36 / .72);
|
|
413
|
+
box-shadow:0 14px 44px rgb(0 0 0 / .42);
|
|
414
|
+
}
|
|
415
|
+
#lensInner::after{display:none !important}
|
|
366
416
|
#lensInner svg,#lensInner img{display:block}
|
|
367
417
|
#lensInner :is(pre,table,svg text,svg foreignObject){cursor:text}
|
|
368
418
|
body:not(.dragging) #lensInner :is(pre,table,svg text,svg foreignObject){user-select:text;-webkit-user-select:text}
|
|
419
|
+
@media (prefers-reduced-motion: reduce){
|
|
420
|
+
#lens,.lensbar,#lensStage{transition:none}
|
|
421
|
+
}
|
|
369
422
|
|
|
370
423
|
/* ── 底部提示 ───────────────────────────────────────────── */
|
|
371
424
|
.hint{
|
package/src/html/canvas-chain.js
CHANGED
|
@@ -210,7 +210,8 @@ if (window.__CLADO_CHAIN__) {
|
|
|
210
210
|
var url = new URL(href, 'https://clado.local/documents/' + window.__CLADO_FILE_PATH__);
|
|
211
211
|
if (!url.pathname.startsWith('/documents/')) return;
|
|
212
212
|
var path = decodeURIComponent(url.pathname.slice('/documents/'.length)), resource = (window.__CLADO_RESOURCES__ || {})[path];
|
|
213
|
-
|
|
213
|
+
var workspace = window.__CLADO_WORKSPACE_ID__ ? '&workspace=' + encodeURIComponent(window.__CLADO_WORKSPACE_ID__) : '';
|
|
214
|
+
if (resource || !window.__CLADO_OFFLINE__) { img.src = resource || '/library/resource?file=' + encodeURIComponent(path) + workspace; img.dataset.chainResource = '1'; }
|
|
214
215
|
} catch (_) {}
|
|
215
216
|
});
|
|
216
217
|
}
|
package/src/html/canvas-ui.css
CHANGED
|
@@ -64,3 +64,66 @@
|
|
|
64
64
|
.clado-ai-selected::after{animation:selection-light-around 8s linear infinite}
|
|
65
65
|
}
|
|
66
66
|
.slice.clado-ai-selected::before,.slice.clado-ai-selected::after{inset:-2px -4px;border-radius:6px}
|
|
67
|
+
@keyframes clado-ai-touch-pulse{
|
|
68
|
+
0%{box-shadow:0 0 0 0 color-mix(in srgb,var(--accent) 55%,transparent),var(--shadow)}
|
|
69
|
+
30%{box-shadow:0 0 0 4px color-mix(in srgb,var(--accent) 32%,transparent),0 10px 30px color-mix(in srgb,var(--accent) 18%,transparent)}
|
|
70
|
+
100%{box-shadow:0 0 0 2px color-mix(in srgb,var(--accent) 16%,transparent),var(--shadow)}
|
|
71
|
+
}
|
|
72
|
+
@keyframes clado-ai-waiting-pulse{
|
|
73
|
+
0%,100%{box-shadow:0 0 0 2px rgb(217 119 6 / .22),0 8px 24px rgb(217 119 6 / .12)}
|
|
74
|
+
50%{box-shadow:0 0 0 4px rgb(217 119 6 / .36),0 10px 28px rgb(217 119 6 / .2)}
|
|
75
|
+
}
|
|
76
|
+
.canvas-card.clado-ai-touched,.mnode.clado-ai-touched{
|
|
77
|
+
border-color:color-mix(in srgb,var(--accent) 62%,var(--line));
|
|
78
|
+
animation:clado-ai-touch-pulse 1.1s cubic-bezier(.22,.75,.24,1) 1 forwards;
|
|
79
|
+
}
|
|
80
|
+
.canvas-card.clado-ai-reading,.mnode.clado-ai-reading{
|
|
81
|
+
border-color:color-mix(in srgb,var(--accent) 40%,var(--line));
|
|
82
|
+
box-shadow:0 0 0 2px color-mix(in srgb,var(--accent) 16%,transparent),var(--shadow);
|
|
83
|
+
}
|
|
84
|
+
.canvas-card.clado-ai-waiting,.mnode.clado-ai-waiting{
|
|
85
|
+
border-color:#d97706;
|
|
86
|
+
animation:clado-ai-waiting-pulse 2.2s ease-in-out infinite;
|
|
87
|
+
}
|
|
88
|
+
[data-theme="dark"] .canvas-card.clado-ai-waiting,[data-theme="dark"] .mnode.clado-ai-waiting{
|
|
89
|
+
border-color:#f59e0b;
|
|
90
|
+
}
|
|
91
|
+
.slice.clado-ai-touched,.slice.clado-ai-reading{
|
|
92
|
+
background:color-mix(in srgb,var(--accent) 7%,transparent);
|
|
93
|
+
border-radius:6px;
|
|
94
|
+
}
|
|
95
|
+
.slice.clado-ai-waiting{
|
|
96
|
+
background:rgb(217 119 6 / .12);
|
|
97
|
+
border-radius:6px;
|
|
98
|
+
}
|
|
99
|
+
@media(prefers-reduced-motion:reduce){
|
|
100
|
+
.canvas-card.clado-ai-touched,.mnode.clado-ai-touched,.canvas-card.clado-ai-waiting,.mnode.clado-ai-waiting{animation:none}
|
|
101
|
+
}
|
|
102
|
+
#cladoAiToast{
|
|
103
|
+
position:fixed;left:50%;bottom:18px;z-index:42;
|
|
104
|
+
display:inline-flex;align-items:center;gap:7px;
|
|
105
|
+
max-width:min(460px,calc(100vw - 40px));padding:7px 14px;
|
|
106
|
+
border:0;border-radius:999px;font-size:12px;font-weight:500;line-height:1.25;
|
|
107
|
+
color:var(--fg);cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
|
|
108
|
+
background:color-mix(in srgb,var(--panel) 78%,transparent);
|
|
109
|
+
backdrop-filter:blur(14px) saturate(145%);-webkit-backdrop-filter:blur(14px) saturate(145%);
|
|
110
|
+
box-shadow:0 6px 24px rgb(0 0 0 / .12);
|
|
111
|
+
opacity:0;transform:translate(-50%,8px);pointer-events:none;
|
|
112
|
+
transition:opacity 180ms cubic-bezier(.22,.75,.24,1),transform 180ms cubic-bezier(.22,.75,.24,1);
|
|
113
|
+
}
|
|
114
|
+
#cladoAiToast.open{opacity:1;transform:translate(-50%,0);pointer-events:auto}
|
|
115
|
+
#cladoAiToast .dot{
|
|
116
|
+
width:7px;height:7px;border-radius:50%;flex:none;
|
|
117
|
+
background:var(--accent);box-shadow:0 0 8px color-mix(in srgb,var(--accent) 70%,transparent);
|
|
118
|
+
}
|
|
119
|
+
#cladoAiToast.waiting .dot{
|
|
120
|
+
background:#d97706;box-shadow:0 0 8px rgb(217 119 6 / .72);
|
|
121
|
+
}
|
|
122
|
+
[data-theme="dark"] #cladoAiToast.waiting .dot{
|
|
123
|
+
background:#f59e0b;box-shadow:0 0 8px rgb(245 158 11 / .75);
|
|
124
|
+
}
|
|
125
|
+
[data-theme="dark"] #cladoAiToast{
|
|
126
|
+
background:color-mix(in srgb,var(--panel) 72%,transparent);
|
|
127
|
+
box-shadow:0 8px 28px rgb(0 0 0 / .36);
|
|
128
|
+
}
|
|
129
|
+
|
package/src/html/page.js
CHANGED
|
@@ -81,9 +81,13 @@ export function renderHtml(doc, diagnostics = [], options = {}) {
|
|
|
81
81
|
|
|
82
82
|
// ★ 替换值一律用函数:这些片段里有大把 `$&` / `$1`,直接给字符串的话
|
|
83
83
|
// String.replace 会把它们当成替换模式解释掉(marked 里就有)。
|
|
84
|
+
const builtInViewPlugins = ['view-cards.js', 'view-mindmap.js', 'view-doc.js']
|
|
85
|
+
.map(name => readFileSync(join(HERE, 'views', name), 'utf8')).join('\n');
|
|
84
86
|
let runtime = readFileSync(join(HERE, 'runtime.js'), 'utf8')
|
|
85
87
|
.replace('/*__CANVAS_CARD__*/', () => readFileSync(join(HERE, 'canvas-card.js'), 'utf8'))
|
|
86
88
|
.replace('/*__MEDIA_ANCHORS__*/', () => readFileSync(join(HERE, 'media-anchors.js'), 'utf8'))
|
|
89
|
+
.replace('/*__VIEW_REGISTRY__*/', () => readFileSync(join(HERE, 'view-registry.js'), 'utf8'))
|
|
90
|
+
.replace('/*__VIEW_PLUGINS__*/', () => builtInViewPlugins)
|
|
87
91
|
.replace('/*__MARKED__*/', () => cjs('marked', read('marked.umd.js')))
|
|
88
92
|
.replace('/*__HLJS__*/', () => (hasCodeBlock(doc) ? cjs('hljs', read('highlight.min.js')) : 'var hljs = null;'))
|
|
89
93
|
.replace('/*__MERMAID__*/', () => (doc.hasMermaid ? read('mermaid.min.js') : ''));
|
package/src/html/plugin-ui.css
CHANGED
|
@@ -44,6 +44,18 @@
|
|
|
44
44
|
z-index: 18;
|
|
45
45
|
font: 13px/1.35 system-ui, sans-serif;
|
|
46
46
|
pointer-events: none;
|
|
47
|
+
opacity: 1;
|
|
48
|
+
transform: translateY(0);
|
|
49
|
+
transition: opacity 160ms ease, transform 160ms ease;
|
|
50
|
+
}
|
|
51
|
+
.clado-plugin-slot.clado-slot-hidden {
|
|
52
|
+
opacity: 0;
|
|
53
|
+
transform: translateY(-4px) scale(.985);
|
|
54
|
+
pointer-events: none;
|
|
55
|
+
}
|
|
56
|
+
.clado-plugin-slot.clado-slot-hidden > * { pointer-events: none; }
|
|
57
|
+
@media (prefers-reduced-motion: reduce) {
|
|
58
|
+
.clado-plugin-slot { transition: none; }
|
|
47
59
|
}
|
|
48
60
|
.clado-plugin-slot[hidden], .clado-plugin-slot [hidden] { display: none !important; }
|
|
49
61
|
.clado-plugin-slot > * { pointer-events: auto; }
|
package/src/html/plugin-ui.js
CHANGED
|
@@ -18,7 +18,9 @@
|
|
|
18
18
|
const region = document.createElement('div');
|
|
19
19
|
region.className = 'clado-plugin-slot';
|
|
20
20
|
region.dataset.slot = slot;
|
|
21
|
-
region.hidden
|
|
21
|
+
region.classList.toggle('clado-slot-hidden', hidden);
|
|
22
|
+
region.setAttribute('aria-hidden', String(hidden));
|
|
23
|
+
region.inert = hidden;
|
|
22
24
|
slots.set(slot, region);
|
|
23
25
|
document.body.append(region);
|
|
24
26
|
}
|
|
@@ -36,7 +38,11 @@
|
|
|
36
38
|
setHidden(next) {
|
|
37
39
|
if (hidden === next) return;
|
|
38
40
|
hidden = next;
|
|
39
|
-
for (const slot of slots.values())
|
|
41
|
+
for (const slot of slots.values()) {
|
|
42
|
+
slot.classList.toggle('clado-slot-hidden', hidden);
|
|
43
|
+
slot.setAttribute('aria-hidden', String(hidden));
|
|
44
|
+
slot.inert = hidden;
|
|
45
|
+
}
|
|
40
46
|
},
|
|
41
47
|
};
|
|
42
48
|
}
|
package/src/html/runtime-api.js
CHANGED
|
@@ -75,17 +75,17 @@
|
|
|
75
75
|
if(saved.width)el.style.width=saved.width;if(saved.height)el.style.height=saved.height;
|
|
76
76
|
});
|
|
77
77
|
canvasSetFocus(canvasRecords[view.focusId] || view.focusId === '__document' ? view.focusId : null);
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
var viewDef = CladoViewRegistry.get(view.mode);
|
|
79
|
+
if (viewDef && typeof viewDef.restore === 'function') viewDef.restore();
|
|
80
80
|
scale = view.scale; tx = view.tx; ty = view.ty; apply(); repinPorts(); drawWires();
|
|
81
81
|
$('#doc').scrollTop = view.scrollTop || 0;
|
|
82
82
|
canvasApplyFocus();
|
|
83
83
|
},
|
|
84
84
|
refresh: function () {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (document.body.dataset.mode !== 'doc') { fit(); repinPorts(); }
|
|
85
|
+
var viewDef = CladoViewRegistry.get(document.body.dataset.mode);
|
|
86
|
+
if (viewDef && typeof viewDef.refresh === 'function') viewDef.refresh();
|
|
88
87
|
},
|
|
88
|
+
views: function () { return CladoViewRegistry.list(); },
|
|
89
89
|
allEdges: function (open) {
|
|
90
90
|
openEdge = {};
|
|
91
91
|
if (open) DOC.edges.forEach(function (e) { openEdge[edgeKey(e[0], e[1])] = 1; });
|
|
@@ -94,5 +94,136 @@
|
|
|
94
94
|
return renderMermaid().then(afterMedia);
|
|
95
95
|
},
|
|
96
96
|
whenMedia: function () { return renderMermaid().then(afterMedia); },
|
|
97
|
+
highlightActivity: function (activity) {
|
|
98
|
+
if (!activity) return;
|
|
99
|
+
var cls = activity.kind === 'read' ? 'clado-ai-reading' : activity.kind === 'waiting' ? 'clado-ai-waiting' : 'clado-ai-touched';
|
|
100
|
+
var paths = Array.isArray(activity.nodes) ? activity.nodes : [];
|
|
101
|
+
var records = Object.values(canvasRecords);
|
|
102
|
+
var matched = [];
|
|
103
|
+
paths.forEach(function (path) {
|
|
104
|
+
if (typeof path === 'string' && path) path = [path];
|
|
105
|
+
if (!Array.isArray(path) || !path.length) return;
|
|
106
|
+
var exact = records.find(function (r) {
|
|
107
|
+
return r.titlePath.length === path.length && path.every(function (p, i) { return p === r.titlePath[i]; });
|
|
108
|
+
});
|
|
109
|
+
if (!exact && path.length > 1) {
|
|
110
|
+
exact = records.find(function (r) { return r.titlePath.length === 1 && r.titlePath[0] === path[0]; });
|
|
111
|
+
}
|
|
112
|
+
if (!exact) {
|
|
113
|
+
var tail = path[path.length - 1];
|
|
114
|
+
exact = records.find(function (r) { return r.title === tail; });
|
|
115
|
+
}
|
|
116
|
+
if (exact) matched.push(exact);
|
|
117
|
+
});
|
|
118
|
+
var mode = document.body.dataset.mode;
|
|
119
|
+
var targets = [];
|
|
120
|
+
matched.forEach(function (rec) {
|
|
121
|
+
if (mode === 'cards') {
|
|
122
|
+
var cardId = rec.card || rec.id;
|
|
123
|
+
if (rec.parent) {
|
|
124
|
+
var sliceEl = $('#world .slice[data-id="' + rec.id + '"]');
|
|
125
|
+
if (sliceEl) targets.push(sliceEl);
|
|
126
|
+
else if (render.card[cardId]) targets.push(render.card[cardId]);
|
|
127
|
+
} else if (render.card[cardId]) {
|
|
128
|
+
targets.push(render.card[cardId]);
|
|
129
|
+
}
|
|
130
|
+
} else if (mode === 'mindmap') {
|
|
131
|
+
var el = $('#mind .mnode[data-path="' + rec.mindPath + '"]');
|
|
132
|
+
if (el) targets.push(el);
|
|
133
|
+
} else if (mode === 'doc') {
|
|
134
|
+
var sec = $('#article .slice[data-path="' + rec.docPath + '"]');
|
|
135
|
+
if (sec) targets.push(sec);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
if (window.__cladoAiHighlightTimer) clearTimeout(window.__cladoAiHighlightTimer);
|
|
139
|
+
$$('.clado-ai-touched, .clado-ai-reading, .clado-ai-waiting').forEach(function (el) {
|
|
140
|
+
el.classList.remove('clado-ai-touched', 'clado-ai-reading', 'clado-ai-waiting');
|
|
141
|
+
});
|
|
142
|
+
targets.forEach(function (el) {
|
|
143
|
+
void el.offsetWidth;
|
|
144
|
+
el.classList.add(cls);
|
|
145
|
+
});
|
|
146
|
+
function smoothPanTo(record) {
|
|
147
|
+
if (!record) return;
|
|
148
|
+
var curMode = document.body.dataset.mode;
|
|
149
|
+
if (curMode === 'doc') {
|
|
150
|
+
canvasRevealDocumentTitle(record);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
var node;
|
|
154
|
+
if (curMode === 'mindmap') node = $('#mind .mnode[data-path="' + (record.id === '__document' ? '0' : record.mindPath) + '"]');
|
|
155
|
+
else node = record.parent ? $('#world .slice[data-id="' + record.id + '"]') : render.card[record.id];
|
|
156
|
+
if (!node) return;
|
|
157
|
+
var rect = node.getBoundingClientRect(), stage = $('#stage').getBoundingClientRect();
|
|
158
|
+
var heading = $('.card-title h1', node) || $('.slice-head', node) || node;
|
|
159
|
+
var headingRect = heading.getBoundingClientRect();
|
|
160
|
+
var nodeLeft = rect.left, headingTop = headingRect.top;
|
|
161
|
+
if (curMode === 'cards') {
|
|
162
|
+
var card = render.card[record.card], destination = pos[record.card];
|
|
163
|
+
if (card && destination) {
|
|
164
|
+
var cardRect = card.getBoundingClientRect();
|
|
165
|
+
nodeLeft = stage.left + tx + destination.x * scale + rect.left - cardRect.left;
|
|
166
|
+
headingTop = stage.top + ty + destination.y * scale + headingRect.top - cardRect.top;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
var dx = stage.left + stage.width / 2 - (nodeLeft + rect.width / 2);
|
|
170
|
+
var dy = stage.top + Math.min(96, Math.max(32, stage.height / 4.5)) - headingTop;
|
|
171
|
+
if (Math.hypot(dx, dy) < 2) return;
|
|
172
|
+
var startTx = tx, startTy = ty, targetTx = tx + dx, targetTy = ty + dy;
|
|
173
|
+
if (window.__cladoPanRaf) { cancelAnimationFrame(window.__cladoPanRaf); window.__cladoPanRaf = 0; }
|
|
174
|
+
var reduced = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
175
|
+
if (reduced) {
|
|
176
|
+
tx = targetTx; ty = targetTy; apply();
|
|
177
|
+
if (curMode === 'mindmap') drawMindWires(); else drawWires();
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
var duration = 280, started = performance.now();
|
|
181
|
+
function step(now) {
|
|
182
|
+
var p = Math.min(1, (now - started) / duration);
|
|
183
|
+
var ease = 1 - Math.pow(1 - p, 3);
|
|
184
|
+
tx = startTx + (targetTx - startTx) * ease;
|
|
185
|
+
ty = startTy + (targetTy - startTy) * ease;
|
|
186
|
+
apply();
|
|
187
|
+
if (document.body.dataset.mode === 'mindmap') drawMindWires(); else drawWires();
|
|
188
|
+
if (p < 1) window.__cladoPanRaf = requestAnimationFrame(step);
|
|
189
|
+
else window.__cladoPanRaf = 0;
|
|
190
|
+
}
|
|
191
|
+
window.__cladoPanRaf = requestAnimationFrame(step);
|
|
192
|
+
}
|
|
193
|
+
if (matched[0] && (activity.forcePan || activity.follow)) {
|
|
194
|
+
smoothPanTo(matched[0]);
|
|
195
|
+
}
|
|
196
|
+
if (activity.label) {
|
|
197
|
+
var toast = document.getElementById('cladoAiToast');
|
|
198
|
+
if (!toast) {
|
|
199
|
+
toast = document.createElement('button');
|
|
200
|
+
toast.id = 'cladoAiToast';
|
|
201
|
+
toast.type = 'button';
|
|
202
|
+
document.body.appendChild(toast);
|
|
203
|
+
}
|
|
204
|
+
toast.classList.toggle('waiting', activity.kind === 'waiting');
|
|
205
|
+
toast.innerHTML = '<span class="dot" aria-hidden="true"></span><span>' + esc(String(activity.label)) + '</span>';
|
|
206
|
+
toast.onclick = function () {
|
|
207
|
+
if (matched[0]) smoothPanTo(matched[0]);
|
|
208
|
+
toast.classList.remove('open');
|
|
209
|
+
};
|
|
210
|
+
requestAnimationFrame(function () { toast.classList.add('open'); });
|
|
211
|
+
}
|
|
212
|
+
var ttl = activity.kind === 'waiting' ? 12000 : activity.kind === 'read' ? 2200 : 3200;
|
|
213
|
+
window.__cladoAiHighlightTimer = setTimeout(function () {
|
|
214
|
+
targets.forEach(function (el) { el.classList.remove('clado-ai-touched', 'clado-ai-reading', 'clado-ai-waiting'); });
|
|
215
|
+
var toast = document.getElementById('cladoAiToast');
|
|
216
|
+
if (toast) toast.classList.remove('open');
|
|
217
|
+
}, ttl);
|
|
218
|
+
},
|
|
219
|
+
focusNodePath: function (path, label) {
|
|
220
|
+
if (!path || (Array.isArray(path) && !path.length)) return;
|
|
221
|
+
window.CladoRuntime.highlightActivity({
|
|
222
|
+
nodes: [path],
|
|
223
|
+
kind: 'read',
|
|
224
|
+
label: label || '',
|
|
225
|
+
forcePan: true,
|
|
226
|
+
});
|
|
227
|
+
},
|
|
97
228
|
closeLens: closeLens
|
|
98
229
|
};
|