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.
@@ -1,41 +1,77 @@
1
1
  /**
2
- * 系统级内置 Agent 人设预设与多会话持久化(.clado/sessions/<id>.json)。
2
+ * 系统级内置 Agent 人设模板、统一多会话池(活跃排序 · 24h 自动归档 · 手动归档/删除 · 轮次快照)与原子级上下文压缩。
3
3
  */
4
4
 
5
5
  import { existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs';
6
6
  import { join } from 'node:path';
7
7
 
8
- export const BUILTIN_PERSONAS = Object.freeze([
8
+ export const SESSION_PALETTE_KEYS = Object.freeze(['blue', 'teal', 'violet', 'amber', 'cyan', 'rose']);
9
+
10
+ export const PERSONA_TEMPLATES = Object.freeze([
9
11
  Object.freeze({
10
12
  id: 'architect',
11
13
  name: '研发架构师',
14
+ pal: 'blue',
12
15
  summary: '严谨查证本地源码,擅长调用链、数据契约与系统边界拆解',
13
16
  prompt: '你是一名资深研发架构师。先看真实代码证据再画设计,严禁编造类名和字段;拆卡片讲究单一职责,跨卡连线必须从具体内容行出发;遇到方案权衡或需求歧义时,主动调用 ask_user 给出清晰选项让用户拍板。',
17
+ initContext: '当核心接口契约卡片定稿后,可通过 spawn_peer 或 message_peer 呼叫下游实现/测试同伴并行跟进。',
18
+ }),
19
+ Object.freeze({
20
+ id: 'coder',
21
+ name: '后端实现者',
22
+ pal: 'teal',
23
+ summary: '依据定稿画布契约编写高内聚代码并通过单测验证',
24
+ prompt: '你是一名务实的后端实现工程师。严格对齐画布中已拍板的接口契约与 Tag 锚点,先读存量代码再做最小侵入实现,完成后主动验证单测或诊断状态。',
25
+ initContext: '收到上游交接后核对幂等与异常分支,跑通相关测试命令后用 notify 同步结论。',
14
26
  }),
15
27
  Object.freeze({
16
28
  id: 'qa',
17
29
  name: 'QA 测试专家',
30
+ pal: 'violet',
18
31
  summary: '擅长脑图测试用例树,系统化覆盖正常、边界、异常与回归点',
19
32
  prompt: '你是一名资深 QA 测试架构师。擅长用脑图结构拆解测试场景,坚持每个模块覆盖正常流、边界条件、异常流和回归检查点;每条用例写清前置条件、操作步骤与可观察预期,不写空泛描述。',
33
+ initContext: '重点审查超时重发、并发重入与空值边界,将用例直接沉淀到 test-cases 画布中。',
20
34
  }),
21
35
  Object.freeze({
22
36
  id: 'auditor',
23
37
  name: '验收审计官',
38
+ pal: 'amber',
24
39
  summary: '对比本地 Git Diff 与画布设计契约,精准指出遗漏与偏离',
25
40
  prompt: '你是一名严谨的交付验收审计官。优先查看本地 git diff 与源码细节,逐项核对实现是否满足画布设计契约和测试用例;清晰列出已满足项、风险偏离项与归档建议。',
41
+ initContext: '默认只读审查签名校验、越权访问与异常吞没风险,发现偏差精准指向对应卡片或代码行。',
26
42
  }),
27
43
  ]);
28
44
 
29
- export function resolvePersona(personaId, customPrompt = '') {
45
+ // 保持既有 3 项 BUILTIN_PERSONAS 导出,确保旧版元信息测试 100% 兼容
46
+ export const BUILTIN_PERSONAS = Object.freeze(
47
+ PERSONA_TEMPLATES.filter(p => p.id !== 'coder').map(({ id, name, summary, prompt }) => Object.freeze({ id, name, summary, prompt })),
48
+ );
49
+
50
+ export function paletteForPersona(personaId, fallbackIdx = 0) {
51
+ const found = PERSONA_TEMPLATES.find(p => p.id === personaId);
52
+ if (found) return found.pal;
53
+ return SESSION_PALETTE_KEYS[Math.abs(Number(fallbackIdx) || 0) % SESSION_PALETTE_KEYS.length];
54
+ }
55
+
56
+ export function resolvePersona(personaId, customPrompt = '', personaOverrides = null) {
30
57
  if (personaId === 'custom' && String(customPrompt || '').trim()) {
31
58
  return {
32
59
  id: 'custom',
33
60
  name: '自定义人设',
61
+ pal: 'cyan',
34
62
  summary: '用户自定义系统提示词',
35
63
  prompt: String(customPrompt).trim().slice(0, 4000),
64
+ initContext: '',
36
65
  };
37
66
  }
38
- return BUILTIN_PERSONAS.find(p => p.id === personaId) || BUILTIN_PERSONAS[0];
67
+ const base = PERSONA_TEMPLATES.find(p => p.id === personaId) || PERSONA_TEMPLATES[0];
68
+ const ov = personaOverrides && typeof personaOverrides === 'object' ? personaOverrides[base.id] : null;
69
+ if (!ov || typeof ov !== 'object') return base;
70
+ return {
71
+ ...base,
72
+ prompt: typeof ov.prompt === 'string' && ov.prompt.trim() ? ov.prompt.trim().slice(0, 4000) : base.prompt,
73
+ initContext: typeof ov.initContext === 'string' ? ov.initContext.trim().slice(0, 2000) : base.initContext,
74
+ };
39
75
  }
40
76
 
41
77
  function sessionsDir(stateDir) {
@@ -44,59 +80,168 @@ function sessionsDir(stateDir) {
44
80
  return dir;
45
81
  }
46
82
 
47
- function safeSessionId(id) {
83
+ export function safeSessionId(id) {
48
84
  if (typeof id !== 'string' || !/^[a-zA-Z0-9_-]{4,80}$/.test(id)) return null;
49
85
  return id;
50
86
  }
51
87
 
88
+ function parseTimestampMs(isoOrMs) {
89
+ if (typeof isoOrMs === 'number' && Number.isFinite(isoOrMs)) return isoOrMs;
90
+ if (typeof isoOrMs === 'string' && isoOrMs) {
91
+ const t = Date.parse(isoOrMs);
92
+ if (Number.isFinite(t)) return t;
93
+ }
94
+ return Date.now();
95
+ }
96
+
52
97
  export function loadSessionRecord(stateDir, id) {
53
98
  const clean = safeSessionId(id);
54
99
  if (!stateDir || !clean) return null;
55
100
  const path = join(sessionsDir(stateDir), clean + '.json');
56
101
  if (!existsSync(path)) return null;
57
- try { return JSON.parse(readFileSync(path, 'utf8')); } catch { return null; }
102
+ try {
103
+ const data = JSON.parse(readFileSync(path, 'utf8'));
104
+ if (!data || typeof data !== 'object') return null;
105
+ return {
106
+ ...data,
107
+ id: data.id || clean,
108
+ persona: data.persona || 'architect',
109
+ pal: data.pal || paletteForPersona(data.persona || 'architect'),
110
+ mode: data.mode || 'design',
111
+ execMode: data.execMode === 'plan' ? 'plan' : 'act',
112
+ archived: Boolean(data.archived),
113
+ lastActiveAt: parseTimestampMs(data.lastActiveAt || data.updatedAt),
114
+ };
115
+ } catch {
116
+ return null;
117
+ }
58
118
  }
59
119
 
60
120
  export function saveSessionRecord(stateDir, record) {
61
121
  const clean = safeSessionId(record?.id);
62
122
  if (!stateDir || !clean) return null;
123
+ const existing = loadSessionRecord(stateDir, clean);
124
+ const nowIso = new Date().toISOString();
125
+ const touchActivity = record.touchActivity !== false;
126
+ const lastActiveAt = touchActivity
127
+ ? (typeof record.lastActiveAt === 'number' ? record.lastActiveAt : Date.now())
128
+ : (existing?.lastActiveAt || Date.now());
129
+ const persona = record.persona || existing?.persona || 'architect';
130
+
63
131
  const payload = {
64
132
  id: clean,
65
- title: String(record.title || '新对话').slice(0, 60),
66
- persona: record.persona || 'architect',
67
- mode: record.mode || 'design',
68
- updatedAt: new Date().toISOString(),
69
- messages: Array.isArray(record.messages) ? record.messages.slice(-40) : [],
70
- uiMessages: Array.isArray(record.uiMessages) ? record.uiMessages.slice(-60) : [],
71
- pendingQuestion: record.pendingQuestion || null,
133
+ title: String(record.title || existing?.title || '新会话').slice(0, 60),
134
+ persona,
135
+ pal: record.pal || existing?.pal || paletteForPersona(persona),
136
+ mode: record.mode || existing?.mode || 'design',
137
+ execMode: (record.execMode || existing?.execMode) === 'plan' ? 'plan' : 'act',
138
+ archived: record.archived !== undefined ? Boolean(record.archived) : Boolean(existing?.archived),
139
+ archivedAt: record.archived ? (record.archivedAt || existing?.archivedAt || nowIso) : null,
140
+ createdAt: existing?.createdAt || record.createdAt || nowIso,
141
+ updatedAt: nowIso,
142
+ lastActiveAt,
143
+ liveStatus: record.liveStatus !== undefined ? String(record.liveStatus || '').slice(0, 120) : (existing?.liveStatus || ''),
144
+ todos: Array.isArray(record.todos) ? record.todos.slice(0, 16) : (Array.isArray(existing?.todos) ? existing.todos : []),
145
+ calledBy: record.calledBy !== undefined ? record.calledBy : (existing?.calledBy || null),
146
+ peerHopCount: typeof record.peerHopCount === 'number' ? record.peerHopCount : (existing?.peerHopCount || 0),
147
+ canvasBaseline: record.canvasBaseline !== undefined ? record.canvasBaseline : (existing?.canvasBaseline || null),
148
+ checkpoints: Array.isArray(record.checkpoints) ? record.checkpoints.slice(-6) : (Array.isArray(existing?.checkpoints) ? existing.checkpoints.slice(-6) : []),
149
+ messages: Array.isArray(record.messages) ? record.messages.slice(-60) : (Array.isArray(existing?.messages) ? existing.messages : []),
150
+ uiMessages: Array.isArray(record.uiMessages) ? record.uiMessages.slice(-80) : (Array.isArray(existing?.uiMessages) ? existing.uiMessages : []),
151
+ pendingQuestion: record.pendingQuestion !== undefined ? record.pendingQuestion : (existing?.pendingQuestion || null),
152
+ pendingCommand: record.pendingCommand !== undefined ? record.pendingCommand : (existing?.pendingCommand || null),
72
153
  };
73
- try { writeFileSync(join(sessionsDir(stateDir), clean + '.json'), JSON.stringify(payload, null, 2) + '\n'); } catch {}
154
+ try {
155
+ writeFileSync(join(sessionsDir(stateDir), clean + '.json'), JSON.stringify(payload, null, 2) + '\n');
156
+ } catch {}
74
157
  return payload;
75
158
  }
76
159
 
77
- export function listSessionRecords(stateDir, limit = 20) {
160
+ export function archiveSessionRecord(stateDir, id, archived = true) {
161
+ const existing = loadSessionRecord(stateDir, id);
162
+ if (!existing) return null;
163
+ return saveSessionRecord(stateDir, {
164
+ ...existing,
165
+ archived: Boolean(archived),
166
+ archivedAt: archived ? new Date().toISOString() : null,
167
+ touchActivity: !archived,
168
+ lastActiveAt: archived ? existing.lastActiveAt : Date.now(),
169
+ });
170
+ }
171
+
172
+ export function listSessionRecords(stateDir, limitOrOptions = 20) {
78
173
  if (!stateDir) return [];
79
174
  const dir = join(stateDir, 'sessions');
80
175
  if (!existsSync(dir) || !lstatSync(dir).isDirectory()) return [];
176
+
177
+ const opts = typeof limitOrOptions === 'number'
178
+ ? { limit: limitOrOptions, includeArchived: false, autoArchiveHours: 24, runningIds: new Set(), now: Date.now() }
179
+ : {
180
+ limit: Number(limitOrOptions?.limit) || 40,
181
+ includeArchived: Boolean(limitOrOptions?.includeArchived),
182
+ autoArchiveHours: limitOrOptions?.autoArchiveHours !== undefined ? Number(limitOrOptions.autoArchiveHours) : 24,
183
+ runningIds: limitOrOptions?.runningIds instanceof Set ? limitOrOptions.runningIds : new Set(),
184
+ now: Number(limitOrOptions?.now) || Date.now(),
185
+ };
186
+
187
+ const ttlMs = opts.autoArchiveHours > 0 ? opts.autoArchiveHours * 3600_000 : 0;
81
188
  const items = [];
189
+
82
190
  for (const entry of readdirSync(dir, { withFileTypes: true })) {
83
191
  if (!entry.isFile() || !entry.name.endsWith('.json')) continue;
192
+ const full = join(dir, entry.name);
84
193
  try {
85
- const data = JSON.parse(readFileSync(join(dir, entry.name), 'utf8'));
194
+ const data = JSON.parse(readFileSync(full, 'utf8'));
195
+ if (!data || !data.id) continue;
196
+ const isRunning = opts.runningIds.has(data.id);
197
+ const lastActiveAt = parseTimestampMs(data.lastActiveAt || data.updatedAt);
198
+ let archived = Boolean(data.archived);
199
+
200
+ // 空闲超期自动归档(默认 24 小时,正在运行或待用户拍板的会话不自动归档)
201
+ if (!archived && !isRunning && !data.pendingQuestion && !data.pendingCommand && ttlMs > 0 && (opts.now - lastActiveAt) >= ttlMs) {
202
+ archived = true;
203
+ data.archived = true;
204
+ data.archivedAt = new Date(opts.now).toISOString();
205
+ try { writeFileSync(full, JSON.stringify(data, null, 2) + '\n'); } catch {}
206
+ }
207
+
208
+ if (archived && !opts.includeArchived) continue;
209
+
210
+ const idleMs = Math.max(0, opts.now - lastActiveAt);
211
+ const active = !archived && (isRunning || idleMs < 30_000);
86
212
  items.push({
87
213
  id: data.id,
88
214
  title: data.title || '未命名会话',
89
215
  persona: data.persona || 'architect',
216
+ pal: data.pal || paletteForPersona(data.persona || 'architect'),
90
217
  mode: data.mode || 'design',
218
+ execMode: data.execMode === 'plan' ? 'plan' : 'act',
219
+ archived,
220
+ archivedAt: data.archivedAt || null,
91
221
  updatedAt: data.updatedAt || '',
92
- hasPendingQuestion: !!data.pendingQuestion,
222
+ lastActiveAt,
223
+ idleSecs: Math.floor(idleMs / 1000),
224
+ active,
225
+ running: isRunning,
226
+ liveStatus: data.liveStatus || '',
227
+ todos: Array.isArray(data.todos) ? data.todos : [],
228
+ calledBy: data.calledBy && (opts.now - (data.calledBy.at || 0) < 8_000) ? data.calledBy : null,
229
+ hasPendingQuestion: Boolean(data.pendingQuestion),
230
+ pendingCommand: data.pendingCommand || null,
93
231
  messageCount: Array.isArray(data.uiMessages) ? data.uiMessages.length : 0,
94
232
  });
95
233
  } catch {}
96
234
  }
235
+
236
+ // 严格按【未归档 -> 30s 内活跃置顶 -> 最近活跃时间倒序】排列
97
237
  return items
98
- .sort((a, b) => String(b.updatedAt).localeCompare(String(a.updatedAt)))
99
- .slice(0, limit);
238
+ .sort((a, b) => {
239
+ if (a.archived !== b.archived) return a.archived ? 1 : -1;
240
+ if (a.active !== b.active) return a.active ? -1 : 1;
241
+ if (b.lastActiveAt !== a.lastActiveAt) return b.lastActiveAt - a.lastActiveAt;
242
+ return String(b.updatedAt).localeCompare(String(a.updatedAt));
243
+ })
244
+ .slice(0, opts.limit);
100
245
  }
101
246
 
102
247
  export function deleteSessionRecord(stateDir, id) {
@@ -108,22 +253,82 @@ export function deleteSessionRecord(stateDir, id) {
108
253
  }
109
254
 
110
255
  /**
111
- * 上下文窗口轻量压缩:总字符超限时保留最早的目标背景 + 最近若干轮完整消息,避免上下文爆炸。
256
+ * 将消息序列按原子交互块分组,严禁从 assistant(tool_calls) 与后续 tool(tool_call_id) 中间切断!
257
+ */
258
+ function groupAtomicMessageBlocks(messages) {
259
+ const blocks = [];
260
+ let i = 0;
261
+ while (i < messages.length) {
262
+ const msg = messages[i];
263
+ if (msg?.role === 'assistant' && Array.isArray(msg.tool_calls) && msg.tool_calls.length > 0) {
264
+ const expectedIds = new Set(msg.tool_calls.map(tc => tc?.id).filter(Boolean));
265
+ const group = [msg];
266
+ let j = i + 1;
267
+ while (j < messages.length && messages[j]?.role === 'tool') {
268
+ group.push(messages[j]);
269
+ expectedIds.delete(messages[j].tool_call_id);
270
+ j++;
271
+ }
272
+ blocks.push(group);
273
+ i = j;
274
+ } else if (msg?.role === 'tool') {
275
+ // 兜底丢弃孤立的游离 tool 结果,防止上游协议报 400
276
+ i += 1;
277
+ } else {
278
+ blocks.push([msg]);
279
+ i += 1;
280
+ }
281
+ }
282
+ return blocks;
283
+ }
284
+
285
+ /**
286
+ * 原子级上下文窗口压缩:支持自定义触发百分比阈值与压缩提示词摘要指引,绝不撕裂 tool_call / tool_result 配对。
112
287
  */
113
- export function compactMessages(messages, maxChars = 36000) {
288
+ export function compactMessages(messages, maxCharsOrOpts = 36000) {
114
289
  if (!Array.isArray(messages) || !messages.length) return [];
290
+ const opts = typeof maxCharsOrOpts === 'number'
291
+ ? { maxChars: maxCharsOrOpts, thresholdPct: 100, compactPrompt: '' }
292
+ : {
293
+ maxChars: Number(maxCharsOrOpts?.maxChars) || 48000,
294
+ thresholdPct: Math.min(95, Math.max(40, Number(maxCharsOrOpts?.thresholdPct) || 75)),
295
+ compactPrompt: String(maxCharsOrOpts?.compactPrompt || '').trim(),
296
+ };
297
+
298
+ const budgetChars = Math.floor(opts.maxChars * (opts.thresholdPct / 100));
299
+ const blocks = groupAtomicMessageBlocks(messages);
300
+ const flatClean = blocks.flat();
115
301
  const sizeOf = list => list.reduce((sum, m) => sum + JSON.stringify(m).length, 0);
116
- if (sizeOf(messages) <= maxChars) return messages;
117
- const keepTail = Math.min(messages.length, 10);
118
- const head = messages.slice(0, messages.length - keepTail);
119
- const tail = messages.slice(-keepTail);
120
- const digest = head
121
- .filter(m => (m.role === 'user' || m.role === 'assistant') && typeof m.content === 'string' && m.content.trim())
122
- .slice(-8)
123
- .map(m => `${m.role === 'user' ? '用户' : 'Agent'}:${m.content.trim().slice(0, 120)}`)
124
- .join('\n');
302
+ if (sizeOf(flatClean) <= budgetChars || blocks.length <= 3) return flatClean;
303
+
304
+ // 从尾部向前保留完整的原子块,确保预算充裕且配对 100% 闭合
305
+ const tailBlocks = [];
306
+ let tailChars = 0;
307
+ const maxTailChars = Math.floor(budgetChars * 0.65);
308
+ for (let idx = blocks.length - 1; idx >= 1; idx--) {
309
+ const bSize = sizeOf(blocks[idx]);
310
+ if (tailBlocks.length >= 2 && tailChars + bSize > maxTailChars) break;
311
+ tailBlocks.unshift(blocks[idx]);
312
+ tailChars += bSize;
313
+ if (tailBlocks.length >= 8) break;
314
+ }
315
+
316
+ const headMessages = blocks.slice(0, blocks.length - tailBlocks.length).flat();
317
+ const digestLines = [];
318
+ for (const m of headMessages) {
319
+ if ((m?.role === 'user' || m?.role === 'assistant') && typeof m.content === 'string' && m.content.trim()) {
320
+ const clean = m.content.replace(/^【前序对话压缩摘要】[\s\S]*?\n\n/, '').trim();
321
+ if (clean) digestLines.push(`${m.role === 'user' ? '用户' : 'Agent'}:${clean.slice(0, 160)}`);
322
+ } else if (m?.role === 'assistant' && Array.isArray(m.tool_calls) && m.tool_calls.length) {
323
+ const names = m.tool_calls.map(tc => tc?.function?.name).filter(Boolean).join(', ');
324
+ if (names) digestLines.push(`Agent 调用工具:${names}`);
325
+ }
326
+ }
327
+
328
+ const guide = opts.compactPrompt ? `(压缩准则:${opts.compactPrompt.slice(0, 240)})\n` : '';
329
+ const digest = digestLines.slice(-12).join('\n');
125
330
  return [
126
- ...(digest ? [{ role: 'user', content: `【前序对话压缩摘要】\n${digest}` }] : []),
127
- ...tail,
331
+ ...(digest ? [{ role: 'user', content: `【前序对话压缩摘要】\n${guide}${digest}` }] : []),
332
+ ...tailBlocks.flat(),
128
333
  ];
129
334
  }
@@ -73,7 +73,12 @@
73
73
  50%{filter:blur(14px) hue-rotate(12deg)}
74
74
  }
75
75
 
76
- /* AI 正在处理 / 生成时的底边柔光呼吸(仅在 AI 活跃状态显示,普通点击/静止卡片零彩边) */
76
+ @keyframes clado-aura-flow{
77
+ 0%{background-position:0% 50%}
78
+ 100%{background-position:200% 50%}
79
+ }
80
+
81
+ /* AI 正在处理 / 生成时的底边流光细条(86% 宽、1px 极细高度、柔和浅色滚动;普通点击/静止卡片零彩边) */
77
82
  .canvas-card:is(.clado-ai-touched,.clado-ai-reading,.clado-ai-waiting):not(.clado-ai-selected),
78
83
  .mnode:is(.clado-ai-touched,.clado-ai-reading,.clado-ai-waiting):not(.clado-ai-selected){
79
84
  border-color:var(--line);
@@ -83,26 +88,24 @@
83
88
  .mnode:is(.clado-ai-touched,.clado-ai-reading):not(.clado-ai-selected)::before{
84
89
  content:"";position:absolute;left:50%;bottom:-.5px;width:86%;height:1px;
85
90
  transform:translateX(-50%);pointer-events:none;z-index:3;
86
- background:linear-gradient(90deg,transparent 0%,rgba(56,189,248,.20) 10%,rgba(56,189,248,.48) 28%,rgba(129,140,248,.62) 50%,rgba(232,121,249,.42) 72%,rgba(244,114,182,.16) 90%,transparent 100%);
91
+ background:linear-gradient(90deg,rgba(98,217,255,.65) 0%,rgba(181,154,255,.68) 25%,rgba(255,144,203,.58) 50%,rgba(98,217,255,.65) 75%,rgba(181,154,255,.68) 100%);
92
+ background-size:200% 100%;
93
+ mask-image:linear-gradient(90deg,transparent 0%,#000 12%,#000 88%,transparent 100%);
94
+ -webkit-mask-image:linear-gradient(90deg,transparent 0%,#000 12%,#000 88%,transparent 100%);
95
+ animation:clado-aura-flow 2.6s linear infinite;
87
96
  }
88
97
  .canvas-card:is(.clado-ai-touched,.clado-ai-reading):not(.clado-ai-selected)::after,
89
98
  .mnode:is(.clado-ai-touched,.clado-ai-reading):not(.clado-ai-selected)::after{
90
- content:"";position:absolute;left:50%;top:calc(100% - 2px);width:96%;height:48px;
99
+ content:"";position:absolute;left:50%;top:calc(100% - 1px);width:96%;height:20px;
91
100
  transform-origin:50% 0%;transform:translateX(-50%);pointer-events:none;z-index:-1;
92
- background:
93
- radial-gradient(ellipse 36% 44% at 30% 6%,rgba(56,189,248,.34) 0%,rgba(56,189,248,.10) 48%,transparent 76%),
94
- radial-gradient(ellipse 34% 52% at 50% 4%,rgba(139,92,246,.34) 0%,rgba(139,92,246,.10) 46%,transparent 74%),
95
- radial-gradient(ellipse 34% 42% at 70% 7%,rgba(244,114,182,.26) 0%,rgba(244,114,182,.08) 44%,transparent 72%);
101
+ background:radial-gradient(ellipse 52% 85% at 50% 0%,rgba(125,180,255,.22),transparent 76%);
96
102
  mask-image:linear-gradient(90deg,transparent 0%,rgba(0,0,0,.42) 12%,#000 32%,#000 68%,rgba(0,0,0,.42) 88%,transparent 100%);
97
103
  -webkit-mask-image:linear-gradient(90deg,transparent 0%,rgba(0,0,0,.42) 12%,#000 32%,#000 68%,rgba(0,0,0,.42) 88%,transparent 100%);
98
104
  animation:clado-aura-breathe 2.9s ease-in-out infinite,clado-aura-drift 5.5s ease-in-out infinite;
99
105
  }
100
106
  [data-theme="dark"] .canvas-card:is(.clado-ai-touched,.clado-ai-reading):not(.clado-ai-selected)::after,
101
107
  [data-theme="dark"] .mnode:is(.clado-ai-touched,.clado-ai-reading):not(.clado-ai-selected)::after{
102
- background:
103
- radial-gradient(ellipse 36% 44% at 30% 6%,rgba(56,189,248,.40) 0%,rgba(56,189,248,.12) 48%,transparent 76%),
104
- radial-gradient(ellipse 34% 52% at 50% 4%,rgba(167,139,250,.38) 0%,rgba(167,139,250,.10) 46%,transparent 74%),
105
- radial-gradient(ellipse 34% 42% at 70% 7%,rgba(244,114,182,.28) 0%,rgba(244,114,182,.08) 44%,transparent 72%);
108
+ background:radial-gradient(ellipse 52% 85% at 50% 0%,rgba(96,165,250,.28),transparent 76%);
106
109
  }
107
110
  .canvas-card.clado-ai-waiting:not(.clado-ai-selected)::before,
108
111
  .mnode.clado-ai-waiting:not(.clado-ai-selected)::before{
@@ -213,3 +216,64 @@
213
216
  }
214
217
  }
215
218
 
219
+ /* ============ 多实例画布组件(便签 sticky 与视图+工具混合组件 widget) ============ */
220
+ [data-mode="mindmap"] .clado-canvas-obj,
221
+ [data-mode="doc"] .clado-canvas-obj{display:none!important}
222
+ .clado-canvas-obj{
223
+ position:absolute;z-index:2;border-radius:14px;
224
+ box-shadow:var(--shadow);user-select:none;-webkit-user-select:none;
225
+ transition:box-shadow 180ms cubic-bezier(.22,1,.36,1),border-color 180ms ease,transform 180ms cubic-bezier(.22,1,.36,1);
226
+ }
227
+ .clado-canvas-obj.dragging{transition:none!important;z-index:5;cursor:grabbing}
228
+ .clado-canvas-obj.clado-obj-selected{
229
+ border-color:var(--accent)!important;
230
+ box-shadow:0 0 0 2px color-mix(in srgb,var(--accent) 26%,transparent),var(--shadow)!important;
231
+ }
232
+ .clado-canvas-obj.sticky{
233
+ padding:10px 12px;
234
+ background:rgba(254,249,195,.93);border:1px solid rgba(234,179,8,.32);color:#422006;
235
+ }
236
+ [data-theme="dark"] .clado-canvas-obj.sticky{
237
+ background:rgba(66,52,18,.90);border-color:rgba(250,204,21,.28);color:#fef08a;
238
+ }
239
+ .clado-canvas-obj.sticky[data-tint="mint"]{background:rgba(209,250,229,.93);border-color:rgba(16,185,129,.30);color:#064e3b}
240
+ [data-theme="dark"] .clado-canvas-obj.sticky[data-tint="mint"]{background:rgba(14,58,46,.90);border-color:rgba(52,211,153,.28);color:#a7f3d0}
241
+ .clado-canvas-obj.sticky[data-tint="lavender"]{background:rgba(237,233,254,.93);border-color:rgba(139,92,246,.30);color:#3b0764}
242
+ [data-theme="dark"] .clado-canvas-obj.sticky[data-tint="lavender"]{background:rgba(46,26,79,.90);border-color:rgba(167,139,250,.28);color:#ddd6fe}
243
+ .clado-canvas-obj.sticky[data-tint="sky"]{background:rgba(224,242,254,.93);border-color:rgba(14,165,233,.30);color:#0c4a6e}
244
+ [data-theme="dark"] .clado-canvas-obj.sticky[data-tint="sky"]{background:rgba(12,45,72,.90);border-color:rgba(56,189,248,.28);color:#bae6fd}
245
+
246
+ .clado-obj-head{
247
+ display:flex;align-items:center;justify-content:space-between;gap:6px;
248
+ font-size:10.5px;font-weight:650;opacity:.78;margin-bottom:4px;cursor:grab;
249
+ }
250
+ .clado-sticky-body{
251
+ font-size:12px;line-height:1.48;font-weight:500;white-space:pre-wrap;overflow-wrap:anywhere;outline:none;min-height:20px;
252
+ }
253
+ .clado-sticky-body[contenteditable="true"]{
254
+ cursor:text;user-select:text;-webkit-user-select:text;
255
+ background:rgba(255,255,255,.35);border-radius:6px;padding:3px 5px;margin:-3px -5px;
256
+ }
257
+ [data-theme="dark"] .clado-sticky-body[contenteditable="true"]{background:rgba(0,0,0,.25)}
258
+
259
+ .clado-canvas-obj.widget{
260
+ padding:11px 13px;background:var(--panel);border:1px solid var(--line);color:var(--fg);
261
+ }
262
+ .clado-track-row{
263
+ display:flex;align-items:center;gap:8px;padding:6px 8px;border-radius:9px;
264
+ border:1px solid transparent;cursor:pointer;transition:background-color 160ms ease,border-color 160ms ease;
265
+ }
266
+ .clado-track-row:hover{background:var(--accent-soft)}
267
+ .clado-track-row.sel-default{border-color:var(--accent);background:var(--accent-soft)}
268
+ .clado-track-row.sel-custom{
269
+ background:linear-gradient(90deg,rgba(139,92,246,.14),rgba(56,189,248,.12));
270
+ border-color:rgba(139,92,246,.48);
271
+ }
272
+ .clado-eq-bars{display:none;align-items:flex-end;gap:2px;height:12px;width:12px;flex:none}
273
+ .clado-track-row.sel-custom .clado-eq-bars{display:inline-flex}
274
+ .clado-eq-bars i{display:block;width:2.5px;border-radius:2px;background:#8b5cf6;animation:cladoEqBounce .8s ease-in-out infinite alternate}
275
+ .clado-eq-bars i:nth-child(2){animation-delay:.2s;background:#3b82f6}
276
+ .clado-eq-bars i:nth-child(3){animation-delay:.4s;background:#ec4899}
277
+ @keyframes cladoEqBounce{from{height:3px}to{height:12px}}
278
+
279
+