claude-code-templates 1.8.3 → 1.10.0

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.
@@ -823,7 +823,7 @@
823
823
 
824
824
  .charts-container {
825
825
  display: grid;
826
- grid-template-columns: 2fr 1fr;
826
+ grid-template-columns: 1fr 1fr;
827
827
  gap: 30px;
828
828
  margin: 20px 0 30px 0;
829
829
  }
@@ -851,6 +851,85 @@
851
851
  height: 200px !important;
852
852
  }
853
853
 
854
+ .tool-summary {
855
+ padding: 20px;
856
+ height: 200px;
857
+ display: flex;
858
+ flex-direction: column;
859
+ gap: 12px;
860
+ overflow-y: auto;
861
+ }
862
+
863
+ .tool-stat {
864
+ display: flex;
865
+ justify-content: space-between;
866
+ align-items: center;
867
+ padding: 8px 12px;
868
+ background: var(--bg-tertiary);
869
+ border: 1px solid var(--border-secondary);
870
+ border-radius: 4px;
871
+ transition: all 0.2s ease;
872
+ font-size: 0.8rem;
873
+ }
874
+
875
+ .tool-stat:hover {
876
+ background: var(--bg-secondary);
877
+ border-color: var(--border-primary);
878
+ }
879
+
880
+ .tool-stat-label {
881
+ color: var(--text-secondary);
882
+ font-weight: 500;
883
+ }
884
+
885
+ .tool-stat-value {
886
+ color: var(--text-primary);
887
+ font-weight: 600;
888
+ }
889
+
890
+ .tool-stat-accent {
891
+ color: var(--text-accent);
892
+ }
893
+
894
+ .tool-top-tool {
895
+ display: flex;
896
+ align-items: center;
897
+ gap: 8px;
898
+ padding: 12px;
899
+ background: var(--bg-tertiary);
900
+ border: 1px solid var(--border-secondary);
901
+ border-radius: 4px;
902
+ margin-top: auto;
903
+ }
904
+
905
+ .tool-icon {
906
+ width: 24px;
907
+ height: 24px;
908
+ background: var(--text-accent);
909
+ border-radius: 4px;
910
+ display: flex;
911
+ align-items: center;
912
+ justify-content: center;
913
+ font-size: 12px;
914
+ color: white;
915
+ }
916
+
917
+ .tool-info {
918
+ flex: 1;
919
+ }
920
+
921
+ .tool-name {
922
+ color: var(--text-primary);
923
+ font-size: 0.8rem;
924
+ font-weight: 600;
925
+ margin-bottom: 2px;
926
+ }
927
+
928
+ .tool-usage {
929
+ color: var(--text-secondary);
930
+ font-size: 0.7rem;
931
+ }
932
+
854
933
  .filter-bar {
855
934
  display: flex;
856
935
  align-items: center;
@@ -1585,6 +1664,22 @@
1585
1664
  </div>
1586
1665
  <canvas id="projectChart" class="chart-canvas"></canvas>
1587
1666
  </div>
1667
+
1668
+ <div class="chart-card">
1669
+ <div class="chart-title">
1670
+ 🛠️ tool usage trends
1671
+ </div>
1672
+ <canvas id="toolChart" class="chart-canvas"></canvas>
1673
+ </div>
1674
+
1675
+ <div class="chart-card">
1676
+ <div class="chart-title">
1677
+ ⚡ tool activity summary
1678
+ </div>
1679
+ <div id="toolSummary" class="tool-summary">
1680
+ <!-- Tool summary will be loaded here -->
1681
+ </div>
1682
+ </div>
1588
1683
  </div>
1589
1684
 
1590
1685
  <div class="filter-bar">
@@ -1662,6 +1757,7 @@
1662
1757
  let currentSession = null;
1663
1758
  let tokenChart = null;
1664
1759
  let projectChart = null;
1760
+ let toolChart = null;
1665
1761
  let allData = null;
1666
1762
  let notificationsEnabled = false;
1667
1763
  let previousConversationStates = new Map();
@@ -2031,6 +2127,12 @@
2031
2127
 
2032
2128
  // Update Project Activity Distribution Chart
2033
2129
  updateProjectChart(data.conversations);
2130
+
2131
+ // Update Tool Usage Trends Chart
2132
+ updateToolChart(data.conversations);
2133
+
2134
+ // Update Tool Activity Summary
2135
+ updateToolSummary(data.conversations);
2034
2136
  }
2035
2137
 
2036
2138
  async function refreshCharts() {
@@ -2279,6 +2381,329 @@
2279
2381
  });
2280
2382
  }
2281
2383
 
2384
+ function updateToolChart(conversations) {
2385
+ // Check if Chart.js is available
2386
+ if (typeof Chart === 'undefined') {
2387
+ console.warn('Chart.js not available for updateToolChart');
2388
+ return;
2389
+ }
2390
+
2391
+ // Apply date filtering to conversations first
2392
+ const { fromDate, toDate } = getDateRange();
2393
+ const filteredConversations = conversations.filter(conv => {
2394
+ const convDate = new Date(conv.lastModified);
2395
+ return convDate >= fromDate && convDate <= toDate;
2396
+ });
2397
+
2398
+ // Aggregate tool usage across filtered conversations
2399
+ const toolTimeline = [];
2400
+ const toolStats = {};
2401
+
2402
+ filteredConversations.forEach(conv => {
2403
+ if (conv.toolUsage && conv.toolUsage.toolTimeline) {
2404
+ conv.toolUsage.toolTimeline.forEach(entry => {
2405
+ const entryDate = new Date(entry.timestamp);
2406
+ // Only include tool usage within date range
2407
+ if (entryDate >= fromDate && entryDate <= toDate) {
2408
+ toolTimeline.push({
2409
+ tool: entry.tool,
2410
+ timestamp: entryDate,
2411
+ date: entryDate.toDateString()
2412
+ });
2413
+
2414
+ toolStats[entry.tool] = (toolStats[entry.tool] || 0) + 1;
2415
+ }
2416
+ });
2417
+ }
2418
+ });
2419
+
2420
+ const ctx = document.getElementById('toolChart').getContext('2d');
2421
+
2422
+ if (toolChart) {
2423
+ toolChart.destroy();
2424
+ }
2425
+
2426
+ if (Object.keys(toolStats).length === 0) {
2427
+ // No tool usage data available
2428
+ toolChart = new Chart(ctx, {
2429
+ type: 'bar',
2430
+ data: {
2431
+ labels: ['No Data'],
2432
+ datasets: [{
2433
+ label: 'Tool Usage',
2434
+ data: [0],
2435
+ backgroundColor: 'rgba(109, 40, 217, 0.6)',
2436
+ borderColor: 'rgba(109, 40, 217, 1)',
2437
+ borderWidth: 1
2438
+ }]
2439
+ },
2440
+ options: {
2441
+ responsive: true,
2442
+ maintainAspectRatio: false,
2443
+ interaction: {
2444
+ intersect: false,
2445
+ mode: 'nearest'
2446
+ },
2447
+ plugins: {
2448
+ legend: {
2449
+ display: false
2450
+ },
2451
+ tooltip: {
2452
+ enabled: true,
2453
+ position: 'nearest',
2454
+ backgroundColor: 'rgba(0, 0, 0, 0.8)',
2455
+ titleColor: '#fff',
2456
+ bodyColor: '#fff',
2457
+ borderColor: 'rgba(255, 255, 255, 0.1)',
2458
+ borderWidth: 1
2459
+ }
2460
+ },
2461
+ scales: {
2462
+ y: {
2463
+ beginAtZero: true,
2464
+ ticks: {
2465
+ color: getComputedStyle(document.documentElement).getPropertyValue('--text-secondary').trim()
2466
+ },
2467
+ grid: {
2468
+ color: getComputedStyle(document.documentElement).getPropertyValue('--border-primary').trim()
2469
+ }
2470
+ },
2471
+ x: {
2472
+ ticks: {
2473
+ color: getComputedStyle(document.documentElement).getPropertyValue('--text-secondary').trim()
2474
+ },
2475
+ grid: {
2476
+ color: getComputedStyle(document.documentElement).getPropertyValue('--border-primary').trim()
2477
+ }
2478
+ }
2479
+ }
2480
+ }
2481
+ });
2482
+ return;
2483
+ }
2484
+
2485
+ // Get top 10 most used tools
2486
+ const sortedTools = Object.entries(toolStats)
2487
+ .sort((a, b) => b[1] - a[1])
2488
+ .slice(0, 10);
2489
+
2490
+ // Generate colors for different tools
2491
+ const colors = [
2492
+ 'rgba(75, 192, 192, 0.6)',
2493
+ 'rgba(255, 99, 132, 0.6)',
2494
+ 'rgba(54, 162, 235, 0.6)',
2495
+ 'rgba(255, 206, 86, 0.6)',
2496
+ 'rgba(153, 102, 255, 0.6)',
2497
+ 'rgba(255, 159, 64, 0.6)',
2498
+ 'rgba(199, 199, 199, 0.6)',
2499
+ 'rgba(83, 102, 255, 0.6)',
2500
+ 'rgba(255, 99, 255, 0.6)',
2501
+ 'rgba(99, 255, 132, 0.6)'
2502
+ ];
2503
+
2504
+ const borderColors = [
2505
+ 'rgba(75, 192, 192, 1)',
2506
+ 'rgba(255, 99, 132, 1)',
2507
+ 'rgba(54, 162, 235, 1)',
2508
+ 'rgba(255, 206, 86, 1)',
2509
+ 'rgba(153, 102, 255, 1)',
2510
+ 'rgba(255, 159, 64, 1)',
2511
+ 'rgba(199, 199, 199, 1)',
2512
+ 'rgba(83, 102, 255, 1)',
2513
+ 'rgba(255, 99, 255, 1)',
2514
+ 'rgba(99, 255, 132, 1)'
2515
+ ];
2516
+
2517
+ // Store sorted tools data for reliable tooltip access
2518
+ window.currentToolData = sortedTools;
2519
+
2520
+ toolChart = new Chart(ctx, {
2521
+ type: 'bar',
2522
+ data: {
2523
+ labels: sortedTools.map(([tool]) => {
2524
+ // Truncate long tool names for display
2525
+ return tool.length > 15 ? tool.substring(0, 15) + '...' : tool;
2526
+ }),
2527
+ datasets: [{
2528
+ label: 'Usage Count',
2529
+ data: sortedTools.map(([, count]) => count),
2530
+ backgroundColor: colors.slice(0, sortedTools.length),
2531
+ borderColor: borderColors.slice(0, sortedTools.length),
2532
+ borderWidth: 1
2533
+ }]
2534
+ },
2535
+ options: {
2536
+ responsive: true,
2537
+ maintainAspectRatio: false,
2538
+ interaction: {
2539
+ intersect: false,
2540
+ mode: 'nearest'
2541
+ },
2542
+ plugins: {
2543
+ legend: {
2544
+ display: false
2545
+ },
2546
+ tooltip: {
2547
+ enabled: true,
2548
+ position: 'nearest',
2549
+ backgroundColor: 'rgba(0, 0, 0, 0.8)',
2550
+ titleColor: '#fff',
2551
+ bodyColor: '#fff',
2552
+ borderColor: 'rgba(255, 255, 255, 0.1)',
2553
+ borderWidth: 1,
2554
+ callbacks: {
2555
+ title: function(tooltipItems) {
2556
+ const index = tooltipItems[0].dataIndex;
2557
+ // Use the stored tool data for reliable access
2558
+ return window.currentToolData && window.currentToolData[index]
2559
+ ? window.currentToolData[index][0]
2560
+ : 'Tool';
2561
+ },
2562
+ label: function(context) {
2563
+ const value = context.parsed.y;
2564
+ const total = window.currentToolData ?
2565
+ window.currentToolData.reduce((sum, [, count]) => sum + count, 0) :
2566
+ context.dataset.data.reduce((sum, val) => sum + val, 0);
2567
+ const percentage = ((value / total) * 100).toFixed(1);
2568
+ return `Used ${value} times (${percentage}%)`;
2569
+ }
2570
+ }
2571
+ }
2572
+ },
2573
+ scales: {
2574
+ y: {
2575
+ beginAtZero: true,
2576
+ ticks: {
2577
+ color: getComputedStyle(document.documentElement).getPropertyValue('--text-secondary').trim(),
2578
+ stepSize: 1
2579
+ },
2580
+ grid: {
2581
+ color: getComputedStyle(document.documentElement).getPropertyValue('--border-primary').trim()
2582
+ }
2583
+ },
2584
+ x: {
2585
+ ticks: {
2586
+ color: getComputedStyle(document.documentElement).getPropertyValue('--text-secondary').trim(),
2587
+ maxRotation: 45,
2588
+ minRotation: 0
2589
+ },
2590
+ grid: {
2591
+ color: getComputedStyle(document.documentElement).getPropertyValue('--border-primary').trim()
2592
+ }
2593
+ }
2594
+ }
2595
+ }
2596
+ });
2597
+ }
2598
+
2599
+ function updateToolSummary(conversations) {
2600
+ // Apply date filtering to conversations first
2601
+ const { fromDate, toDate } = getDateRange();
2602
+ const filteredConversations = conversations.filter(conv => {
2603
+ const convDate = new Date(conv.lastModified);
2604
+ return convDate >= fromDate && convDate <= toDate;
2605
+ });
2606
+
2607
+ // Aggregate tool usage across filtered conversations
2608
+ const toolStats = {};
2609
+ let totalToolCalls = 0;
2610
+ let conversationsWithTools = 0;
2611
+ let totalUniqueTools = new Set();
2612
+
2613
+ filteredConversations.forEach(conv => {
2614
+ if (conv.toolUsage && conv.toolUsage.toolTimeline) {
2615
+ let convHasTools = false;
2616
+ conv.toolUsage.toolTimeline.forEach(entry => {
2617
+ const entryDate = new Date(entry.timestamp);
2618
+ // Only include tool usage within date range
2619
+ if (entryDate >= fromDate && entryDate <= toDate) {
2620
+ toolStats[entry.tool] = (toolStats[entry.tool] || 0) + 1;
2621
+ totalToolCalls++;
2622
+ totalUniqueTools.add(entry.tool);
2623
+ convHasTools = true;
2624
+ }
2625
+ });
2626
+ if (convHasTools) {
2627
+ conversationsWithTools++;
2628
+ }
2629
+ }
2630
+ });
2631
+
2632
+ const summaryElement = document.getElementById('toolSummary');
2633
+
2634
+ if (totalToolCalls === 0) {
2635
+ summaryElement.innerHTML = `
2636
+ <div class="tool-stat">
2637
+ <span class="tool-stat-label">No tool usage data available</span>
2638
+ <span class="tool-stat-value">📊</span>
2639
+ </div>
2640
+ `;
2641
+ return;
2642
+ }
2643
+
2644
+ // Find most used tool
2645
+ const sortedTools = Object.entries(toolStats).sort((a, b) => b[1] - a[1]);
2646
+ const topTool = sortedTools[0];
2647
+ const avgToolsPerConv = conversationsWithTools > 0 ? (totalToolCalls / conversationsWithTools).toFixed(1) : 0;
2648
+
2649
+ // Calculate tool diversity using Shannon Diversity Index (more accurate)
2650
+ const toolCount = sortedTools.length;
2651
+ let shannonIndex = 0;
2652
+ let diversityScore = 0;
2653
+
2654
+ if (toolCount > 1) {
2655
+ // Calculate Shannon diversity index
2656
+ sortedTools.forEach(([, count]) => {
2657
+ const proportion = count / totalToolCalls;
2658
+ if (proportion > 0) {
2659
+ shannonIndex -= proportion * Math.log2(proportion);
2660
+ }
2661
+ });
2662
+
2663
+ // Normalize to 0-100% scale
2664
+ const maxDiversity = Math.log2(toolCount); // Maximum possible diversity
2665
+ diversityScore = (shannonIndex / maxDiversity) * 100;
2666
+ }
2667
+ // If only one tool used, diversityScore remains 0
2668
+
2669
+ summaryElement.innerHTML = `
2670
+ <div class="tool-stat">
2671
+ <span class="tool-stat-label">Total Tool Calls</span>
2672
+ <span class="tool-stat-value tool-stat-accent">${totalToolCalls}</span>
2673
+ </div>
2674
+
2675
+ <div class="tool-stat">
2676
+ <span class="tool-stat-label">Unique Tools Used</span>
2677
+ <span class="tool-stat-value">${totalUniqueTools.size}</span>
2678
+ </div>
2679
+
2680
+ <div class="tool-stat">
2681
+ <span class="tool-stat-label">Conversations with Tools</span>
2682
+ <span class="tool-stat-value">${conversationsWithTools}/${filteredConversations.length}</span>
2683
+ </div>
2684
+
2685
+ <div class="tool-stat">
2686
+ <span class="tool-stat-label">Avg Tools per Conversation</span>
2687
+ <span class="tool-stat-value">${avgToolsPerConv}</span>
2688
+ </div>
2689
+
2690
+ <div class="tool-stat" title="How evenly distributed tool usage is. 100% = perfectly balanced, 0% = concentrated in few tools">
2691
+ <span class="tool-stat-label">Tool Balance Score</span>
2692
+ <span class="tool-stat-value">${diversityScore.toFixed(0)}%</span>
2693
+ </div>
2694
+
2695
+ ${topTool ? `
2696
+ <div class="tool-top-tool">
2697
+ <div class="tool-icon">🏆</div>
2698
+ <div class="tool-info">
2699
+ <div class="tool-name">Most Used: ${topTool[0]}</div>
2700
+ <div class="tool-usage">${topTool[1]} calls (${((topTool[1] / totalToolCalls) * 100).toFixed(1)}%)</div>
2701
+ </div>
2702
+ </div>
2703
+ ` : ''}
2704
+ `;
2705
+ }
2706
+
2282
2707
  function updateSessionsTable() {
2283
2708
  const tableBody = document.getElementById('sessionsTable');
2284
2709
  const noSessionsDiv = document.getElementById('noSessions');
@@ -2867,7 +3292,7 @@
2867
3292
  localStorage.setItem('claude-analytics-theme', theme);
2868
3293
 
2869
3294
  // Update charts if they exist to use new theme colors
2870
- if (tokenChart || projectChart) {
3295
+ if (tokenChart || projectChart || toolChart) {
2871
3296
  setTimeout(() => {
2872
3297
  if (allData) {
2873
3298
  updateCharts(allData);