cladogram 0.6.0-beta.8 → 0.6.0-beta.9

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.
@@ -1524,3 +1524,167 @@ body.clado-dock-resizing iframe {
1524
1524
  background: var(--clado-ui-hover);
1525
1525
  border-color: var(--clado-ui-prism-border);
1526
1526
  }
1527
+
1528
+ /* =========================================================================
1529
+ Settings Center v2 (5 Groups · 16 Dedicated Directories · Searchable)
1530
+ ========================================================================= */
1531
+ .clado-settings-shell-v2 {
1532
+ width: min(1080px, 95vw);
1533
+ height: min(780px, 90vh);
1534
+ }
1535
+ .clado-settings-nav-v2 {
1536
+ width: 244px;
1537
+ min-width: 224px;
1538
+ padding: 14px 10px 12px;
1539
+ display: flex;
1540
+ flex-direction: column;
1541
+ gap: 10px;
1542
+ }
1543
+ .clado-snav-top {
1544
+ display: flex;
1545
+ flex-direction: column;
1546
+ gap: 6px;
1547
+ flex: none;
1548
+ }
1549
+ .clado-snav-search {
1550
+ display: flex;
1551
+ align-items: center;
1552
+ gap: 7px;
1553
+ padding: 6px 10px;
1554
+ border-radius: 10px;
1555
+ border: 1px solid var(--clado-ui-well-border);
1556
+ background: var(--clado-ui-well);
1557
+ color: var(--clado-ui-muted);
1558
+ }
1559
+ .clado-snav-search input {
1560
+ border: 0;
1561
+ background: transparent;
1562
+ color: var(--clado-ui-text);
1563
+ font: inherit;
1564
+ font-size: 12px;
1565
+ width: 100%;
1566
+ outline: none;
1567
+ }
1568
+ .clado-snav-groups {
1569
+ flex: 1;
1570
+ min-height: 0;
1571
+ overflow-y: auto;
1572
+ display: flex;
1573
+ flex-direction: column;
1574
+ gap: 12px;
1575
+ padding-right: 2px;
1576
+ }
1577
+ .clado-snav-group {
1578
+ display: flex;
1579
+ flex-direction: column;
1580
+ gap: 2px;
1581
+ }
1582
+ .clado-snav-group-title {
1583
+ font-size: 10.5px;
1584
+ font-weight: 640;
1585
+ letter-spacing: 0.03em;
1586
+ text-transform: uppercase;
1587
+ color: var(--clado-ui-subtle);
1588
+ padding: 2px 10px 4px;
1589
+ }
1590
+ .clado-settings-nav-v2 .clado-snav-btn {
1591
+ padding: 7px 10px;
1592
+ font-size: 12.5px;
1593
+ border-radius: 9px;
1594
+ }
1595
+ .clado-snav-foot {
1596
+ flex: none;
1597
+ padding-top: 6px;
1598
+ border-top: 1px solid var(--clado-ui-edge);
1599
+ }
1600
+ .clado-settings-body-v2 {
1601
+ padding: 22px 26px 28px;
1602
+ gap: 14px;
1603
+ }
1604
+ .clado-set-head {
1605
+ display: flex;
1606
+ align-items: flex-start;
1607
+ justify-content: space-between;
1608
+ gap: 14px;
1609
+ flex-wrap: wrap;
1610
+ }
1611
+ .clado-set-title {
1612
+ font-size: 18px;
1613
+ font-weight: 640;
1614
+ letter-spacing: -0.015em;
1615
+ }
1616
+ .clado-set-sub {
1617
+ font-size: 12.5px;
1618
+ color: var(--clado-ui-muted);
1619
+ margin-top: 4px;
1620
+ line-height: 1.5;
1621
+ }
1622
+ .clado-set-sub code {
1623
+ font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
1624
+ font-size: 11.5px;
1625
+ }
1626
+ .clado-set-card {
1627
+ display: flex;
1628
+ flex-direction: column;
1629
+ gap: 11px;
1630
+ }
1631
+ .clado-set-card-title {
1632
+ font-size: 13px;
1633
+ font-weight: 620;
1634
+ color: var(--clado-ui-text);
1635
+ }
1636
+ .clado-scope-bar {
1637
+ display: flex;
1638
+ align-items: center;
1639
+ justify-content: space-between;
1640
+ gap: 10px;
1641
+ flex-wrap: wrap;
1642
+ padding: 8px 12px;
1643
+ border-radius: 12px;
1644
+ border: 1px solid var(--clado-ui-well-border);
1645
+ background: var(--clado-ui-well);
1646
+ }
1647
+ .clado-path-pill {
1648
+ font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
1649
+ font-size: 11px;
1650
+ color: var(--clado-ui-muted);
1651
+ word-break: break-all;
1652
+ }
1653
+ .clado-subtabs {
1654
+ display: flex;
1655
+ align-items: center;
1656
+ gap: 6px;
1657
+ flex-wrap: wrap;
1658
+ }
1659
+ .clado-subtabs .clado-ui-button {
1660
+ min-height: 28px;
1661
+ padding: 4px 12px;
1662
+ font-size: 12px;
1663
+ }
1664
+ .clado-mode-card {
1665
+ display: flex;
1666
+ align-items: flex-start;
1667
+ gap: 8px;
1668
+ padding: 10px 12px;
1669
+ border-radius: 11px;
1670
+ border: 1px solid var(--clado-ui-well-border);
1671
+ background: var(--clado-ui-well);
1672
+ cursor: pointer;
1673
+ transition: border-color 140ms ease, background-color 140ms ease;
1674
+ }
1675
+ .clado-mode-card input {
1676
+ margin-top: 3px;
1677
+ flex: none;
1678
+ }
1679
+ .clado-mode-card.active {
1680
+ border-color: var(--clado-ui-prism-border);
1681
+ background: var(--clado-ui-prism-bg);
1682
+ }
1683
+ :root[data-clado-density="compact"] .clado-settings-body-v2 { padding: 16px 20px; gap: 10px; }
1684
+ :root[data-clado-density="compact"] .clado-well-box { padding: 10px 12px; border-radius: 12px; }
1685
+ :root[data-clado-density="comfortable"] .clado-settings-body-v2 { padding: 26px 32px; gap: 18px; }
1686
+
1687
+ @media (max-width: 780px) {
1688
+ .clado-settings-shell-v2 { flex-direction: column; height: 92vh; }
1689
+ .clado-settings-nav-v2 { width: 100%; max-height: 210px; border-right: 0; border-bottom: 1px solid var(--clado-ui-edge); }
1690
+ }
@@ -21,11 +21,13 @@ import {
21
21
  createCladoModelRuntime,
22
22
  listPiMcpServers,
23
23
  readCladoPlatformContext,
24
+ readMemoryBundle,
24
25
  readPluginParams,
25
26
  readRuntimeSettings,
26
27
  resolvePiAgentDir,
27
28
  resolveRole,
28
29
  } from './pi-config.js';
30
+ import { createCladoGuardAndHooksExtension } from './pi-hooks-perms.js';
29
31
  import { createCladoPiTools } from './clado-tools.js';
30
32
  import { workspacePath } from '../workspace/documents.js';
31
33
 
@@ -299,6 +301,72 @@ export function deleteSession(stateDir, id, agentDir = resolvePiAgentDir()) {
299
301
  return { deleted: next.length !== list.length, id };
300
302
  }
301
303
 
304
+ export function clearArchivedSessions(stateDir, agentDir = resolvePiAgentDir()) {
305
+ const list = ensureDefaultSessions(stateDir, agentDir);
306
+ const archived = list.filter(s => s.archived);
307
+ let removed = 0;
308
+ for (const s of archived) {
309
+ const r = deleteSession(stateDir, s.id, agentDir);
310
+ if (r.deleted) removed++;
311
+ }
312
+ return { ok: true, removed };
313
+ }
314
+
315
+ export function exportSessionTranscript(stateDir, id, format = 'md', agentDir = resolvePiAgentDir()) {
316
+ const session = getSessionMeta(stateDir, id, agentDir, { includeAll: true });
317
+ if (!session) throw new Error('找不到目标会话。');
318
+ const msgs = Array.isArray(session.messages) ? session.messages : [];
319
+ if (format === 'json') {
320
+ return {
321
+ ok: true,
322
+ format: 'json',
323
+ fileName: `${safeSessionId(session.id)}.json`,
324
+ content: JSON.stringify({
325
+ id: session.id,
326
+ title: session.title,
327
+ roleId: session.roleId,
328
+ model: session.model || '',
329
+ createdAt: session.createdAt,
330
+ updatedAt: session.updatedAt,
331
+ archived: Boolean(session.archived),
332
+ messages: msgs,
333
+ }, null, 2) + '\n',
334
+ };
335
+ }
336
+ const lines = [
337
+ `# ${session.title || session.id}`,
338
+ '',
339
+ `- 会话 ID: \`${session.id}\``,
340
+ `- 角色: \`${session.roleId}\``,
341
+ ...(session.model ? [`- 模型: \`${session.model}\``] : []),
342
+ `- 导出时间: ${new Date().toISOString()}`,
343
+ '',
344
+ '---',
345
+ '',
346
+ ];
347
+ for (const m of msgs) {
348
+ const who = m.role === 'user' ? '## User' : m.role === 'system' ? '## System' : '## Assistant';
349
+ lines.push(who, '');
350
+ if (m.thinking) {
351
+ lines.push('<details><summary>Thinking</summary>', '', m.thinking, '', '</details>', '');
352
+ }
353
+ if (m.text) lines.push(String(m.text), '');
354
+ if (Array.isArray(m.tools) && m.tools.length) {
355
+ lines.push('**Tools:**', '');
356
+ for (const t of m.tools) {
357
+ lines.push(`- \`${t.name}\` (${t.status || 'done'})${t.summary ? ': ' + String(t.summary).slice(0, 160) : ''}`);
358
+ }
359
+ lines.push('');
360
+ }
361
+ }
362
+ return {
363
+ ok: true,
364
+ format: 'md',
365
+ fileName: `${safeSessionId(session.id)}.md`,
366
+ content: lines.join('\n'),
367
+ };
368
+ }
369
+
302
370
  export function captureCanvasSnapshot(documentRoot, file) {
303
371
  if (!documentRoot || !file) return null;
304
372
  try {
@@ -571,10 +639,11 @@ export function createPiBridge({
571
639
  'clado_create', 'clado_update', 'clado_nodes', 'clado_links', 'clado_documents', 'clado_batch',
572
640
  'edit', 'write', 'bash', 'ask_user', 'canvas_objects_upsert', 'canvas_objects_delete',
573
641
  ]);
574
- const createBuiltInPiExtensions = agentDir => [
642
+ const createBuiltInPiExtensions = (agentDir, { workspace = '', getAskUser = null, getRoleTools = null } = {}) => [
575
643
  { name: 'codemode', factory: createCodemodeExtension(), replaceable: true, builtin: true },
576
644
  { name: 'tool-search', factory: createToolSearchExtension(), replaceable: true, builtin: true },
577
645
  { name: 'mcp', factory: createMcpExtension({ logPath: join(agentDir, 'mcp.log') }), replaceable: true, builtin: true },
646
+ { name: 'clado-guard-hooks', factory: createCladoGuardAndHooksExtension({ workspace, agentDir, getAskUser, getRoleTools }), replaceable: true, builtin: true },
578
647
  ];
579
648
  const shutdownAndDisposeSession = async session => {
580
649
  if (!session) return;
@@ -1482,16 +1551,25 @@ export function createPiBridge({
1482
1551
  onCardChanges: (...a) => turnHooksRef.current?.onCardChanges?.(...a),
1483
1552
  });
1484
1553
 
1554
+ const memoryBundle = readMemoryBundle(workspace, agentDir);
1555
+ const scopedRulesContext = memoryBundle.rules.length
1556
+ ? ['# Project Scoped Rules (.clado/rules/)', ...memoryBundle.rules.map(r => `## Rule: ${r.name}\n${r.content.trim()}`)].join('\n\n')
1557
+ : '';
1485
1558
  const loader = new DefaultResourceLoader({
1486
1559
  cwd: workspace,
1487
1560
  agentDir,
1488
1561
  settingsManager: sm,
1489
1562
  noThemes: true,
1490
1563
  packageCommandOutput: 'capture',
1491
- extensionFactories: createBuiltInPiExtensions(agentDir),
1564
+ extensionFactories: createBuiltInPiExtensions(agentDir, {
1565
+ workspace,
1566
+ getAskUser: () => turnHooksRef.current?.askUser || null,
1567
+ getRoleTools: () => ({ tools: role.tools || [], disabledTools: role.disabledTools || [] }),
1568
+ }),
1492
1569
  appendSystemPrompt: [
1493
1570
  role.systemPrompt,
1494
1571
  platformContext,
1572
+ scopedRulesContext,
1495
1573
  pluginParamsContext,
1496
1574
  ].filter(Boolean),
1497
1575
  });
@@ -1537,8 +1615,9 @@ export function createPiBridge({
1537
1615
 
1538
1616
  session = activeWarmEntry.session;
1539
1617
  try {
1540
- if (runtimeSettings.thinkingLevel && typeof session.setThinkingLevel === 'function') {
1541
- session.setThinkingLevel(runtimeSettings.thinkingLevel);
1618
+ const effectiveThink = role.thinkingLevel || runtimeSettings.thinkingLevel;
1619
+ if (effectiveThink && typeof session.setThinkingLevel === 'function') {
1620
+ session.setThinkingLevel(effectiveThink);
1542
1621
  }
1543
1622
  } catch {}
1544
1623
 
@@ -2253,7 +2332,7 @@ export function createPiBridge({
2253
2332
  settingsManager: sm,
2254
2333
  noThemes: true,
2255
2334
  packageCommandOutput: 'capture',
2256
- extensionFactories: createBuiltInPiExtensions(agentDir),
2335
+ extensionFactories: createBuiltInPiExtensions(agentDir, { workspace }),
2257
2336
  });
2258
2337
  await loader.reload();
2259
2338