klaude-code 2.8.0__py3-none-any.whl → 2.9.0__py3-none-any.whl

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.
Files changed (100) hide show
  1. klaude_code/app/runtime.py +2 -1
  2. klaude_code/auth/antigravity/oauth.py +0 -9
  3. klaude_code/auth/antigravity/token_manager.py +0 -18
  4. klaude_code/auth/base.py +53 -0
  5. klaude_code/auth/codex/exceptions.py +0 -4
  6. klaude_code/auth/codex/oauth.py +32 -28
  7. klaude_code/auth/codex/token_manager.py +0 -18
  8. klaude_code/cli/cost_cmd.py +128 -39
  9. klaude_code/cli/list_model.py +27 -10
  10. klaude_code/cli/main.py +15 -4
  11. klaude_code/config/assets/builtin_config.yaml +8 -24
  12. klaude_code/config/config.py +47 -25
  13. klaude_code/config/sub_agent_model_helper.py +18 -13
  14. klaude_code/config/thinking.py +0 -8
  15. klaude_code/const.py +2 -2
  16. klaude_code/core/agent_profile.py +11 -53
  17. klaude_code/core/compaction/compaction.py +4 -6
  18. klaude_code/core/compaction/overflow.py +0 -4
  19. klaude_code/core/executor.py +51 -5
  20. klaude_code/core/manager/llm_clients.py +9 -1
  21. klaude_code/core/prompts/prompt-claude-code.md +4 -4
  22. klaude_code/core/reminders.py +21 -23
  23. klaude_code/core/task.py +0 -4
  24. klaude_code/core/tool/__init__.py +3 -2
  25. klaude_code/core/tool/file/apply_patch.py +0 -27
  26. klaude_code/core/tool/file/edit_tool.py +1 -2
  27. klaude_code/core/tool/file/read_tool.md +3 -2
  28. klaude_code/core/tool/file/read_tool.py +15 -2
  29. klaude_code/core/tool/offload.py +0 -35
  30. klaude_code/core/tool/sub_agent/__init__.py +6 -0
  31. klaude_code/core/tool/sub_agent/image_gen.md +16 -0
  32. klaude_code/core/tool/sub_agent/image_gen.py +146 -0
  33. klaude_code/core/tool/sub_agent/task.md +20 -0
  34. klaude_code/core/tool/sub_agent/task.py +205 -0
  35. klaude_code/core/tool/tool_registry.py +0 -16
  36. klaude_code/core/turn.py +1 -1
  37. klaude_code/llm/anthropic/input.py +6 -5
  38. klaude_code/llm/antigravity/input.py +14 -7
  39. klaude_code/llm/codex/client.py +22 -0
  40. klaude_code/llm/codex/prompt_sync.py +237 -0
  41. klaude_code/llm/google/client.py +8 -6
  42. klaude_code/llm/google/input.py +20 -12
  43. klaude_code/llm/image.py +18 -11
  44. klaude_code/llm/input_common.py +14 -6
  45. klaude_code/llm/json_stable.py +37 -0
  46. klaude_code/llm/openai_compatible/input.py +0 -10
  47. klaude_code/llm/openai_compatible/stream.py +16 -1
  48. klaude_code/llm/registry.py +0 -5
  49. klaude_code/llm/responses/input.py +15 -5
  50. klaude_code/llm/usage.py +0 -8
  51. klaude_code/protocol/commands.py +1 -0
  52. klaude_code/protocol/events.py +2 -1
  53. klaude_code/protocol/message.py +2 -2
  54. klaude_code/protocol/model.py +20 -1
  55. klaude_code/protocol/op.py +27 -0
  56. klaude_code/protocol/op_handler.py +10 -0
  57. klaude_code/protocol/sub_agent/AGENTS.md +5 -5
  58. klaude_code/protocol/sub_agent/__init__.py +13 -34
  59. klaude_code/protocol/sub_agent/explore.py +7 -34
  60. klaude_code/protocol/sub_agent/image_gen.py +3 -74
  61. klaude_code/protocol/sub_agent/task.py +3 -47
  62. klaude_code/protocol/sub_agent/web.py +8 -52
  63. klaude_code/protocol/tools.py +2 -0
  64. klaude_code/session/export.py +308 -299
  65. klaude_code/session/session.py +58 -21
  66. klaude_code/session/store.py +0 -4
  67. klaude_code/session/templates/export_session.html +430 -134
  68. klaude_code/skill/assets/deslop/SKILL.md +9 -0
  69. klaude_code/skill/system_skills.py +0 -20
  70. klaude_code/tui/command/__init__.py +3 -0
  71. klaude_code/tui/command/continue_cmd.py +34 -0
  72. klaude_code/tui/command/fork_session_cmd.py +5 -2
  73. klaude_code/tui/command/resume_cmd.py +9 -2
  74. klaude_code/tui/command/sub_agent_model_cmd.py +85 -18
  75. klaude_code/tui/components/assistant.py +0 -26
  76. klaude_code/tui/components/command_output.py +3 -1
  77. klaude_code/tui/components/developer.py +3 -0
  78. klaude_code/tui/components/diffs.py +2 -208
  79. klaude_code/tui/components/errors.py +4 -0
  80. klaude_code/tui/components/mermaid_viewer.py +2 -2
  81. klaude_code/tui/components/rich/markdown.py +60 -63
  82. klaude_code/tui/components/rich/theme.py +2 -0
  83. klaude_code/tui/components/sub_agent.py +2 -46
  84. klaude_code/tui/components/thinking.py +0 -33
  85. klaude_code/tui/components/tools.py +43 -21
  86. klaude_code/tui/input/images.py +21 -18
  87. klaude_code/tui/input/key_bindings.py +2 -2
  88. klaude_code/tui/input/prompt_toolkit.py +49 -49
  89. klaude_code/tui/machine.py +15 -11
  90. klaude_code/tui/renderer.py +12 -20
  91. klaude_code/tui/runner.py +2 -1
  92. klaude_code/tui/terminal/image.py +6 -34
  93. klaude_code/ui/common.py +0 -70
  94. {klaude_code-2.8.0.dist-info → klaude_code-2.9.0.dist-info}/METADATA +3 -6
  95. {klaude_code-2.8.0.dist-info → klaude_code-2.9.0.dist-info}/RECORD +97 -92
  96. klaude_code/core/tool/sub_agent_tool.py +0 -126
  97. klaude_code/llm/openai_compatible/tool_call_accumulator.py +0 -108
  98. klaude_code/tui/components/rich/searchable_text.py +0 -68
  99. {klaude_code-2.8.0.dist-info → klaude_code-2.9.0.dist-info}/WHEEL +0 -0
  100. {klaude_code-2.8.0.dist-info → klaude_code-2.9.0.dist-info}/entry_points.txt +0 -0
@@ -202,86 +202,6 @@
202
202
  display: block;
203
203
  }
204
204
 
205
- /* Task: one user message + full agent run */
206
- .task {
207
- margin-bottom: 24px;
208
- }
209
-
210
- .task:last-child {
211
- margin-bottom: 0;
212
- }
213
-
214
- /* Task steps: fold intermediate events by default */
215
- details.task-steps {
216
- margin: 6px 0 0 0;
217
- background: transparent;
218
- }
219
-
220
- details.task-steps > summary {
221
- list-style: none;
222
- user-select: none;
223
- cursor: pointer;
224
- display: inline-flex;
225
- align-items: center;
226
- gap: 8px;
227
- padding: 4px 10px;
228
- border-radius: 999px;
229
- border: 1px solid var(--border);
230
- background: var(--bg-card);
231
- color: var(--text-dim);
232
- font-family: var(--font-mono);
233
- font-size: var(--font-size-xs);
234
- line-height: 1.2;
235
- transition: color 0.2s, border-color 0.2s, background 0.2s;
236
- }
237
-
238
- details.task-steps > summary::-webkit-details-marker {
239
- display: none;
240
- }
241
-
242
- details.task-steps > summary::before {
243
- content: "▶";
244
- font-size: 0.8em;
245
- color: var(--accent);
246
- transform: translateY(-0.05em);
247
- transition: transform 0.2s;
248
- }
249
-
250
- details.task-steps[open] > summary {
251
- color: var(--accent);
252
- border-color: var(--accent);
253
- background: var(--accent-dim);
254
- }
255
-
256
- details.task-steps[open] > summary::before {
257
- transform: rotate(90deg) translateY(-0.05em);
258
- }
259
-
260
- details.task-steps > summary:hover {
261
- color: var(--text);
262
- border-color: var(--accent);
263
- }
264
-
265
- details.task-steps > .task-steps-content {
266
- margin-top: 12px;
267
- padding: 0 0 0 18px;
268
- margin-left: 10px;
269
- border-left: 2px solid var(--border);
270
- }
271
-
272
- /* When expanded, hide compact final answer to avoid duplication */
273
- .task details.task-steps[open] ~ .task-final {
274
- display: none;
275
- }
276
-
277
- .task-final {
278
- margin-top: 12px;
279
- }
280
-
281
- .task-mermaid-result {
282
- margin: 12px 0;
283
- }
284
-
285
205
  .message-group {
286
206
  display: flex;
287
207
  flex-direction: column;
@@ -614,12 +534,14 @@
614
534
  border-radius: var(--radius-md);
615
535
  overflow: hidden;
616
536
  font-size: var(--font-size-base);
537
+ /* Ensure background color to avoid gaps being transparent */
538
+ background: var(--bg-card); /* Using bg-card to unify */
617
539
  }
618
540
 
619
541
  .tool-header {
620
542
  padding: 8px 12px;
621
543
  background: var(--bg-container);
622
- border-bottom: 1px solid var(--border);
544
+ /* border-bottom removed to unify look */
623
545
  display: flex;
624
546
  justify-content: space-between;
625
547
  align-items: center;
@@ -666,11 +588,14 @@
666
588
 
667
589
  /* Collapsible tool-args */
668
590
  details.tool-args-collapsible {
669
- padding: 0;
670
591
  background: var(--bg-body);
592
+ margin: 6px 12px;
593
+ border: 1px solid var(--border);
594
+ border-radius: var(--radius-sm);
595
+ overflow: hidden;
671
596
  }
672
597
  details.tool-args-collapsible > summary {
673
- padding: 8px 12px;
598
+ padding: 6px 10px;
674
599
  font-family: var(--font-mono);
675
600
  font-size: var(--font-size-xs);
676
601
  text-transform: uppercase;
@@ -683,11 +608,17 @@
683
608
  gap: 8px;
684
609
  color: var(--text-dim);
685
610
  transition: color 0.2s;
611
+ border-radius: var(--radius-sm);
686
612
  }
687
613
  details.tool-args-collapsible > summary:hover,
688
614
  details.tool-args-collapsible[open] > summary {
689
615
  color: var(--text);
690
616
  }
617
+ details.tool-args-collapsible[open] > summary {
618
+ border-bottom: 1px solid var(--border);
619
+ border-bottom-left-radius: 0;
620
+ border-bottom-right-radius: 0;
621
+ }
691
622
  details.tool-args-collapsible > summary::-webkit-details-marker {
692
623
  display: none;
693
624
  }
@@ -702,17 +633,17 @@
702
633
  content: "[-]";
703
634
  }
704
635
  details.tool-args-collapsible > .tool-args-content {
705
- padding: 12px;
636
+ padding: 10px;
706
637
  font-family: var(--font-mono);
707
638
  color: var(--text-dim);
708
639
  overflow-x: auto;
709
640
  white-space: pre-wrap;
710
641
  font-size: var(--font-size-sm);
711
- border-top: 1px dashed var(--border);
642
+ /* border-top handled by summary bottom border when open */
712
643
  }
713
644
 
714
645
  .tool-result {
715
- border-top: 1px solid var(--border);
646
+ /* border-top removed to unify look */
716
647
  padding: 12px;
717
648
  font-size: var(--font-size-sm);
718
649
  }
@@ -726,14 +657,46 @@
726
657
  .tool-result.success {
727
658
  background: var(--bg-card);
728
659
  color: var(--text);
660
+ --mask-bg: var(--bg-card);
729
661
  }
730
662
  .tool-result.error {
731
663
  background: var(--bg-error);
732
664
  color: var(--error);
665
+ --mask-bg: var(--bg-error);
733
666
  }
734
667
  .tool-result.pending {
735
668
  background: var(--bg-body);
736
669
  color: var(--text-dim);
670
+ --mask-bg: var(--bg-body);
671
+ }
672
+
673
+ /* Tool Output Collapsing */
674
+ .expandable-tool-output {
675
+ position: relative;
676
+ display: block;
677
+ }
678
+ .tool-output-preview {
679
+ position: relative;
680
+ max-height: 200px;
681
+ overflow: hidden;
682
+ transition: max-height 0.3s ease-out;
683
+ }
684
+ .tool-output-preview.expanded {
685
+ max-height: none;
686
+ overflow: visible;
687
+ }
688
+ .tool-output-preview:not(.expanded)::after {
689
+ content: "";
690
+ position: absolute;
691
+ bottom: 0;
692
+ left: 0;
693
+ right: 0;
694
+ height: 60px;
695
+ background: linear-gradient(to bottom, transparent 0%, var(--mask-bg, var(--bg-card)) 100%);
696
+ pointer-events: none;
697
+ }
698
+ .tool-output-preview.expanded + .expand-control {
699
+ display: none;
737
700
  }
738
701
 
739
702
  /* Sub-Agent Result */
@@ -744,6 +707,69 @@
744
707
  margin-top: 8px;
745
708
  }
746
709
 
710
+ /* Mermaid Special Layout */
711
+ .mermaid-container {
712
+ background: white;
713
+ padding: 16px;
714
+ border-radius: 4px;
715
+ border: 1px solid var(--border);
716
+ /* No top margin needed inside wrapper */
717
+ }
718
+ .mermaid-tool-call {
719
+ position: relative;
720
+ background: var(--bg-card);
721
+ border: 1px solid var(--border);
722
+ border-radius: var(--radius-md);
723
+ overflow: hidden;
724
+ display: flex;
725
+ flex-direction: column;
726
+ }
727
+ .mermaid-tool-call .mermaid-view {
728
+ position: relative;
729
+ order: 1;
730
+ }
731
+ .mermaid-tool-call .mermaid-container {
732
+ /* Override border/margin for cleaner look inside the wrapper */
733
+ border: none;
734
+ border-radius: 0;
735
+ margin: 0;
736
+ }
737
+
738
+ .mermaid-info-btn {
739
+ position: absolute;
740
+ top: 12px;
741
+ right: 12px;
742
+ width: 24px;
743
+ height: 24px;
744
+ border-radius: 50%;
745
+ background: var(--bg-card);
746
+ border: 1px solid var(--border);
747
+ color: var(--text-dim);
748
+ font-family: var(--font-mono);
749
+ font-weight: bold;
750
+ font-size: 14px;
751
+ display: flex;
752
+ align-items: center;
753
+ justify-content: center;
754
+ cursor: pointer;
755
+ opacity: 0.6;
756
+ transition: all 0.2s;
757
+ z-index: 5;
758
+ }
759
+ .mermaid-info-btn:hover {
760
+ opacity: 1;
761
+ color: var(--accent);
762
+ border-color: var(--accent);
763
+ transform: scale(1.1);
764
+ box-shadow: 0 2px 8px rgba(0,0,0,0.1);
765
+ }
766
+
767
+ .mermaid-meta {
768
+ border-bottom: 1px solid var(--border);
769
+ background: var(--bg-container);
770
+ order: -1;
771
+ }
772
+
747
773
  .sub-agent-toolbar {
748
774
  display: flex;
749
775
  justify-content: flex-end;
@@ -1411,6 +1437,176 @@
1411
1437
  font-weight: bold;
1412
1438
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
1413
1439
  }
1440
+
1441
+ /* Header Controls */
1442
+ .header-controls {
1443
+ margin-top: 16px;
1444
+ display: flex;
1445
+ justify-content: flex-end;
1446
+ }
1447
+
1448
+ .verbose-btn {
1449
+ display: inline-flex;
1450
+ align-items: center;
1451
+ gap: 8px;
1452
+ padding: 4px 12px;
1453
+ border: 1px solid var(--border);
1454
+ border-radius: 999px;
1455
+ cursor: pointer;
1456
+ font-family: var(--font-mono);
1457
+ font-size: var(--font-size-xs);
1458
+ color: var(--text-dim);
1459
+ background: transparent;
1460
+ transition: all 0.2s ease;
1461
+ user-select: none;
1462
+ }
1463
+
1464
+ .verbose-btn:hover {
1465
+ color: var(--text);
1466
+ border-color: var(--accent);
1467
+ }
1468
+
1469
+ .verbose-btn.active {
1470
+ background: var(--accent-dim);
1471
+ color: var(--accent);
1472
+ border-color: var(--accent);
1473
+ }
1474
+
1475
+ .verbose-btn input {
1476
+ display: none;
1477
+ }
1478
+
1479
+ .verbose-icon {
1480
+ font-family: var(--font-mono);
1481
+ font-weight: bold;
1482
+ /* Revert display/box properties from checkmark style */
1483
+ display: inline;
1484
+ width: auto;
1485
+ height: auto;
1486
+ border: none;
1487
+ border-radius: 0;
1488
+ position: static;
1489
+ transition: none;
1490
+ }
1491
+
1492
+ /* Remove checkmark styles */
1493
+ .verbose-btn.active .verbose-icon {
1494
+ background: transparent;
1495
+ border-color: transparent;
1496
+ }
1497
+ .verbose-btn.active .verbose-icon::after {
1498
+ content: none;
1499
+ }
1500
+
1501
+ /* Verbose Mode Visibility Logic */
1502
+ body:not(.verbose-mode) .thinking-block,
1503
+ body:not(.verbose-mode) details.developer-message,
1504
+ body:not(.verbose-mode) .response-metadata {
1505
+ display: none !important;
1506
+ }
1507
+
1508
+ .turn-collapsible {
1509
+ margin: 16px 0;
1510
+ }
1511
+
1512
+ .turn-collapse-btn {
1513
+ border: 1px solid var(--border);
1514
+ border-radius: 999px;
1515
+ background: transparent;
1516
+ color: var(--text-dim);
1517
+ font-family: var(--font-mono);
1518
+ font-size: var(--font-size-xs);
1519
+ padding: 4px 12px;
1520
+ cursor: pointer;
1521
+ display: inline-flex;
1522
+ align-items: center;
1523
+ gap: 6px;
1524
+ transition: all 0.2s;
1525
+ }
1526
+
1527
+ .turn-collapse-btn:hover {
1528
+ color: var(--text);
1529
+ border-color: var(--accent);
1530
+ }
1531
+
1532
+ .turn-collapse-btn.expanded {
1533
+ color: var(--accent);
1534
+ border-color: var(--accent);
1535
+ background: var(--accent-dim);
1536
+ }
1537
+
1538
+ .turn-steps {
1539
+ margin-top: 8px;
1540
+ padding-left: 16px;
1541
+ border-left: 2px solid var(--border);
1542
+ }
1543
+
1544
+ /* Collapsible Markdown (Sub-agent) */
1545
+ .expandable-markdown {
1546
+ position: relative;
1547
+ display: block;
1548
+ }
1549
+ .markdown-preview {
1550
+ position: relative;
1551
+ max-height: 300px;
1552
+ overflow: hidden;
1553
+ transition: max-height 0.3s ease-out;
1554
+ }
1555
+ .markdown-preview.expanded {
1556
+ max-height: none;
1557
+ overflow: visible;
1558
+ }
1559
+ /* Mask for preview state */
1560
+ .markdown-preview:not(.expanded)::after {
1561
+ content: "";
1562
+ position: absolute;
1563
+ bottom: 0;
1564
+ left: 0;
1565
+ right: 0;
1566
+ height: 60px;
1567
+ background: linear-gradient(to bottom, transparent 0%, var(--bg-card) 100%);
1568
+ pointer-events: none;
1569
+ }
1570
+
1571
+ .expand-control {
1572
+ display: flex;
1573
+ justify-content: center;
1574
+ margin-top: -20px; /* Pull button up into mask area */
1575
+ position: relative;
1576
+ z-index: 10;
1577
+ padding-bottom: 8px;
1578
+ }
1579
+ .markdown-preview.expanded + .expand-control {
1580
+ display: none;
1581
+ }
1582
+
1583
+ .expand-btn {
1584
+ background: var(--bg-card);
1585
+ border: 1px solid var(--border);
1586
+ border-radius: 999px;
1587
+ padding: 4px 16px;
1588
+ font-size: var(--font-size-xs);
1589
+ color: var(--accent);
1590
+ cursor: pointer;
1591
+ font-family: var(--font-mono);
1592
+ box-shadow: 0 2px 4px rgba(0,0,0,0.05);
1593
+ transition: all 0.2s;
1594
+ }
1595
+ .expand-btn:hover {
1596
+ border-color: var(--accent);
1597
+ color: var(--text);
1598
+ box-shadow: 0 4px 8px rgba(0,0,0,0.1);
1599
+ }
1600
+
1601
+ /* Mask for Tool Output */
1602
+ .expandable-output {
1603
+ position: relative;
1604
+ }
1605
+ .expandable-output:not(.expanded) .preview-text {
1606
+ /* Add mask to the text container itself */
1607
+ -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 24px), transparent 100%);
1608
+ mask-image: linear-gradient(to bottom, black calc(100% - 24px), transparent 100%);
1609
+ }
1414
1610
  </style>
1415
1611
  </head>
1416
1612
  <body>
@@ -1432,6 +1628,13 @@
1432
1628
  <span class="meta-value" title="$work_dir_full">$work_dir</span>
1433
1629
  </div>
1434
1630
  </div>
1631
+ <div class="header-controls">
1632
+ <label class="verbose-btn" id="verbose-label">
1633
+ <input type="checkbox" id="verbose-toggle" />
1634
+ <span class="verbose-icon">[+]</span>
1635
+ <span class="verbose-text">Verbose</span>
1636
+ </label>
1637
+ </div>
1435
1638
  </div>
1436
1639
 
1437
1640
  <details class="collapsible-section">
@@ -1516,21 +1719,6 @@
1516
1719
  el.textContent = el.textContent.trim();
1517
1720
  });
1518
1721
 
1519
- // Task steps toggle label
1520
- document.querySelectorAll("details.task-steps").forEach((details) => {
1521
- const summary = details.querySelector("summary");
1522
- const count = details.getAttribute("data-step-count");
1523
- if (!summary || !count) return;
1524
-
1525
- const setLabel = () => {
1526
- summary.textContent =
1527
- (details.open ? "Hide" : "Show") + " " + count + " steps";
1528
- };
1529
-
1530
- setLabel();
1531
- details.addEventListener("toggle", setLabel);
1532
- });
1533
-
1534
1722
  // Process markdown for collapsible sections
1535
1723
  // foldH2: if true, H2 headers start collapsed; otherwise all headers start open
1536
1724
  function structureMarkdown(root, foldH2 = false) {
@@ -1917,44 +2105,70 @@
1917
2105
  });
1918
2106
  }
1919
2107
 
1920
- // 2. Tasks (User + final Assistant)
2108
+ // 2. Messages and Tools
1921
2109
  const stream = document.querySelector(".message-stream");
1922
2110
  if (stream) {
1923
- Array.from(stream.querySelectorAll(":scope > .task")).forEach((task) => {
1924
- const userBlock = task.querySelector(":scope > .message-group");
1925
- if (userBlock) {
1926
- const roleLabel = userBlock.querySelector(".role-label");
1927
- if (roleLabel && roleLabel.classList.contains("user")) {
1928
- userCount++;
1929
- userBlock.id =
1930
- userBlock.id || "user-" + Math.random().toString(36).substr(2, 9);
1931
- sections.push({
1932
- id: userBlock.id,
1933
- label: "USER " + userCount,
1934
- el: userBlock,
1935
- });
2111
+ // Use a Walker to find top-level relevant items if structure is complex
2112
+ // But assuming flat children of message-stream based on CSS
2113
+ Array.from(stream.children).forEach((child) => {
2114
+ let label = null;
2115
+ let idPrefix = "section";
2116
+
2117
+ if (child.classList.contains("message-group")) {
2118
+ const roleLabel = child.querySelector(".role-label");
2119
+ if (roleLabel) {
2120
+ if (roleLabel.classList.contains("user")) {
2121
+ userCount++;
2122
+ label = `USER $$$${userCount}`;
2123
+ idPrefix = "user";
2124
+ } else if (roleLabel.classList.contains("assistant")) {
2125
+ assistantCount++;
2126
+ label = `ASSISTANT $$$${assistantCount}`;
2127
+ idPrefix = "assistant";
2128
+ } else {
2129
+ label = roleLabel.textContent.trim();
2130
+ }
2131
+ }
2132
+ } else if (child.classList.contains("tool-call")) {
2133
+ const toolName = child.querySelector(".tool-name");
2134
+ if (toolName) {
2135
+ label = toolName.textContent.trim();
2136
+ idPrefix = "tool";
2137
+
2138
+ // Try to extract description for Sub Agents
2139
+ try {
2140
+ const argsContent = child.querySelector(".tool-args-content");
2141
+ if (argsContent) {
2142
+ const argsText = argsContent.textContent.trim();
2143
+ if (argsText.startsWith("{")) {
2144
+ const args = JSON.parse(argsText);
2145
+ if (
2146
+ args &&
2147
+ typeof args.description === "string" &&
2148
+ args.description.trim()
2149
+ ) {
2150
+ let desc = args.description.trim();
2151
+ if (desc.length > 30) {
2152
+ desc = desc.substring(0, 30) + "…";
2153
+ }
2154
+ label = label + " - " + desc;
2155
+ }
2156
+ }
2157
+ }
2158
+ } catch (e) {
2159
+ // Ignore JSON parse errors
2160
+ }
2161
+ } else {
2162
+ label = "Tool";
1936
2163
  }
1937
2164
  }
1938
2165
 
1939
- const finalContainer = task.querySelector(":scope > .task-final");
1940
- if (!finalContainer) return;
1941
-
1942
- Array.from(finalContainer.querySelectorAll(":scope > .message-group")).forEach(
1943
- (child) => {
1944
- const roleLabel = child.querySelector(".role-label");
1945
- if (!roleLabel || !roleLabel.classList.contains("assistant")) return;
1946
-
1947
- assistantCount++;
1948
- child.id =
1949
- child.id ||
1950
- "assistant-" + Math.random().toString(36).substr(2, 9);
1951
- sections.push({
1952
- id: child.id,
1953
- label: "ASSISTANT " + assistantCount,
1954
- el: child,
1955
- });
1956
- }
1957
- );
2166
+ if (label) {
2167
+ child.id =
2168
+ child.id ||
2169
+ `$$$${idPrefix}-$$$${Math.random().toString(36).substr(2, 9)}`;
2170
+ sections.push({ id: child.id, label: label, el: child });
2171
+ }
1958
2172
  });
1959
2173
  }
1960
2174
 
@@ -2023,6 +2237,88 @@
2023
2237
  // Initial update
2024
2238
  updateActiveSection();
2025
2239
  });
2240
+
2241
+ // Mermaid info toggle
2242
+ document.querySelectorAll('.mermaid-info-btn').forEach(btn => {
2243
+ btn.addEventListener('click', (e) => {
2244
+ e.stopPropagation(); // prevent collapsing turn
2245
+ const container = btn.closest('.mermaid-tool-call');
2246
+ const meta = container.querySelector('.mermaid-meta');
2247
+ if (meta) {
2248
+ const isHidden = meta.style.display === 'none';
2249
+ meta.style.display = isHidden ? 'block' : 'none';
2250
+ btn.style.color = isHidden ? 'var(--accent)' : '';
2251
+ btn.style.borderColor = isHidden ? 'var(--accent)' : '';
2252
+ btn.style.opacity = isHidden ? '1' : '';
2253
+ }
2254
+ });
2255
+ });
2256
+
2257
+ // Turn collapsing
2258
+ document.querySelectorAll('.turn-collapse-btn').forEach(btn => {
2259
+ btn.addEventListener('click', () => {
2260
+ const container = btn.parentElement;
2261
+ const steps = container.querySelector('.turn-steps');
2262
+ const isHidden = steps.style.display === 'none';
2263
+
2264
+ steps.style.display = isHidden ? 'block' : 'none';
2265
+ btn.classList.toggle('expanded', isHidden);
2266
+
2267
+ const icon = btn.querySelector('.collapse-icon');
2268
+ if (icon) icon.textContent = isHidden ? '[-]' : '[+]';
2269
+ });
2270
+ });
2271
+
2272
+ // Expandable content (Sub-agent markdown & Tool output)
2273
+ document.body.addEventListener('click', (e) => {
2274
+ if (e.target.classList.contains('expand-btn')) {
2275
+ const container = e.target.closest('.expandable-markdown, .expandable-tool-output');
2276
+ if (container) {
2277
+ const preview = container.querySelector('.markdown-preview, .tool-output-preview');
2278
+ if (preview) {
2279
+ preview.classList.add('expanded');
2280
+ }
2281
+ }
2282
+ }
2283
+ });
2284
+
2285
+ // Verbose Toggle
2286
+ const verboseToggle = document.getElementById('verbose-toggle');
2287
+ const verboseLabel = document.getElementById('verbose-label');
2288
+ let isVerbose = false;
2289
+
2290
+ function updateVerboseUI() {
2291
+ const icon = verboseLabel ? verboseLabel.querySelector('.verbose-icon') : null;
2292
+
2293
+ if (isVerbose) {
2294
+ document.body.classList.add('verbose-mode');
2295
+ if (verboseLabel) verboseLabel.classList.add('active');
2296
+ if (icon) icon.textContent = '[-]';
2297
+ } else {
2298
+ document.body.classList.remove('verbose-mode');
2299
+ if (verboseLabel) verboseLabel.classList.remove('active');
2300
+ if (icon) icon.textContent = '[+]';
2301
+ // Enforce collapsing of details when switching to non-verbose
2302
+ document.querySelectorAll('details.tool-args-collapsible, details.diff-collapsible, details.sub-agent-session').forEach(el => {
2303
+ el.removeAttribute('open');
2304
+ });
2305
+ }
2306
+ }
2307
+
2308
+ if (verboseToggle) {
2309
+ verboseToggle.addEventListener('change', (e) => {
2310
+ isVerbose = e.target.checked;
2311
+ updateVerboseUI();
2312
+ });
2313
+
2314
+ // Initialize state (default false)
2315
+ // Also force close any initially open details if non-verbose
2316
+ if (!isVerbose) {
2317
+ document.querySelectorAll('details.tool-args-collapsible, details.diff-collapsible, details.sub-agent-session').forEach(el => {
2318
+ el.removeAttribute('open');
2319
+ });
2320
+ }
2321
+ }
2026
2322
  </script>
2027
2323
  </body>
2028
2324
  </html>
@@ -12,6 +12,15 @@ Remove AI-generated slop from code. Check the specified files or diff and remove
12
12
  - Extra comments that a human wouldn't add or are inconsistent with the rest of the file
13
13
  - Extra defensive checks or try/catch blocks that are abnormal for that area of the codebase (especially if called by trusted/validated codepaths)
14
14
  - Casts to `any` or `# type: ignore` to get around type issues
15
+ - Unnecessary complexity and nesting that reduces readability
16
+ - Redundant abstractions or over-engineered solutions
15
17
  - Any other style that is inconsistent with the file
16
18
 
19
+ ## Principles
20
+
21
+ 1. **Preserve functionality**: Never change what the code does - only how it does it
22
+ 2. **Prefer clarity over brevity**: Explicit readable code is better than overly compact solutions
23
+ 3. **Avoid over-simplification**: Don't create overly clever solutions that are hard to understand or debug
24
+ 4. **Focus scope**: Only refine the specified files or recently modified code, unless instructed otherwise
25
+
17
26
  Report at the end with only a 1-3 sentence summary of what you changed.