claude-code-templates 1.5.7 → 1.5.8

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/analytics.js +98 -26
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-templates",
3
- "version": "1.5.7",
3
+ "version": "1.5.8",
4
4
  "description": "CLI tool to setup Claude Code configurations with framework-specific commands, automation hooks and MCP Servers for your projects",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/analytics.js CHANGED
@@ -830,6 +830,28 @@ async function createWebDashboard() {
830
830
  .detail-actions {
831
831
  display: flex;
832
832
  gap: 12px;
833
+ align-items: center;
834
+ }
835
+
836
+ .export-format-select {
837
+ background: #21262d;
838
+ border: 1px solid #30363d;
839
+ color: #c9d1d9;
840
+ padding: 6px 12px;
841
+ border-radius: 4px;
842
+ font-family: inherit;
843
+ font-size: 0.875rem;
844
+ cursor: pointer;
845
+ }
846
+
847
+ .export-format-select:focus {
848
+ outline: none;
849
+ border-color: #d57455;
850
+ }
851
+
852
+ .export-format-select option {
853
+ background: #21262d;
854
+ color: #c9d1d9;
833
855
  }
834
856
 
835
857
  .btn {
@@ -1036,7 +1058,11 @@ async function createWebDashboard() {
1036
1058
  <div class="detail-header">
1037
1059
  <div class="detail-title" id="detailTitle">session details</div>
1038
1060
  <div class="detail-actions">
1039
- <button class="btn" onclick="exportSessionCSV()">export csv</button>
1061
+ <select id="exportFormat" class="export-format-select">
1062
+ <option value="csv">CSV</option>
1063
+ <option value="json">JSON</option>
1064
+ </select>
1065
+ <button class="btn" onclick="exportSession()">export</button>
1040
1066
  <button class="btn btn-primary" onclick="refreshSessionDetail()">refresh</button>
1041
1067
  </div>
1042
1068
  </div>
@@ -1295,43 +1321,89 @@ async function createWebDashboard() {
1295
1321
  return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
1296
1322
  }
1297
1323
 
1298
- function exportSessionCSV() {
1324
+ function exportSession() {
1299
1325
  if (!currentSession) return;
1300
1326
 
1301
- // Create CSV content
1302
- let csvContent = 'Session ID,Project,Message Count,Tokens,File Size,Created,Last Modified,Status\\n';
1303
- csvContent += \`"\${currentSession.id}","\${currentSession.project}",\${currentSession.messageCount},\${currentSession.tokens},\${currentSession.fileSize},"\${new Date(currentSession.created).toISOString()}","\${new Date(currentSession.lastModified).toISOString()}","\${currentSession.status}"\\n\\n\`;
1304
-
1305
- csvContent += 'Message #,Role,Content\\n';
1327
+ const format = document.getElementById('exportFormat').value;
1306
1328
 
1307
- // Add conversation history if loaded
1329
+ // Fetch conversation history and export
1308
1330
  fetch(\`/api/session/\${currentSession.id}\`)
1309
1331
  .then(response => response.json())
1310
1332
  .then(sessionData => {
1311
- if (sessionData.messages) {
1312
- sessionData.messages.forEach((message, index) => {
1313
- const content = (message.content || 'no content').replace(/"/g, '""');
1314
- csvContent += \`\${index + 1},"\${message.role}","\${content}"\\n\`;
1315
- });
1333
+ if (format === 'csv') {
1334
+ exportSessionAsCSV(sessionData);
1335
+ } else if (format === 'json') {
1336
+ exportSessionAsJSON(sessionData);
1316
1337
  }
1317
-
1318
- // Download CSV
1319
- const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
1320
- const link = document.createElement('a');
1321
- const url = URL.createObjectURL(blob);
1322
- link.setAttribute('href', url);
1323
- link.setAttribute('download', \`claude-session-\${currentSession.id.substring(0, 8)}.csv\`);
1324
- link.style.visibility = 'hidden';
1325
- document.body.appendChild(link);
1326
- link.click();
1327
- document.body.removeChild(link);
1328
1338
  })
1329
1339
  .catch(error => {
1330
- console.error('Failed to export CSV:', error);
1331
- alert('Failed to export CSV. Please try again.');
1340
+ console.error(\`Failed to export \${format.toUpperCase()}:\`, error);
1341
+ alert(\`Failed to export \${format.toUpperCase()}. Please try again.\`);
1332
1342
  });
1333
1343
  }
1334
1344
 
1345
+ function exportSessionAsCSV(sessionData) {
1346
+ // Create CSV content
1347
+ let csvContent = 'Session ID,Project,Message Count,Tokens,File Size,Created,Last Modified,Conversation State,Status\\n';
1348
+ csvContent += \`"\${currentSession.id}","\${currentSession.project}",\${currentSession.messageCount},\${currentSession.tokens},\${currentSession.fileSize},"\${new Date(currentSession.created).toISOString()}","\${new Date(currentSession.lastModified).toISOString()}","\${currentSession.conversationState}","\${currentSession.status}"\\n\\n\`;
1349
+
1350
+ csvContent += 'Message #,Role,Timestamp,Content\\n';
1351
+
1352
+ // Add conversation history
1353
+ if (sessionData.messages) {
1354
+ sessionData.messages.forEach((message, index) => {
1355
+ const content = (message.content || 'no content').replace(/"/g, '""');
1356
+ const timestamp = message.timestamp ? new Date(message.timestamp).toISOString() : 'unknown';
1357
+ csvContent += \`\${index + 1},"\${message.role}","\${timestamp}","\${content}"\\n\`;
1358
+ });
1359
+ }
1360
+
1361
+ // Download CSV
1362
+ const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
1363
+ downloadFile(blob, \`claude-session-\${currentSession.id.substring(0, 8)}.csv\`);
1364
+ }
1365
+
1366
+ function exportSessionAsJSON(sessionData) {
1367
+ // Create comprehensive JSON export
1368
+ const exportData = {
1369
+ session: {
1370
+ id: currentSession.id,
1371
+ filename: currentSession.filename,
1372
+ project: currentSession.project,
1373
+ messageCount: currentSession.messageCount,
1374
+ tokens: currentSession.tokens,
1375
+ fileSize: currentSession.fileSize,
1376
+ created: currentSession.created,
1377
+ lastModified: currentSession.lastModified,
1378
+ conversationState: currentSession.conversationState,
1379
+ status: currentSession.status
1380
+ },
1381
+ messages: sessionData.messages || [],
1382
+ metadata: {
1383
+ exportedAt: new Date().toISOString(),
1384
+ exportFormat: 'json',
1385
+ toolVersion: '1.5.7'
1386
+ }
1387
+ };
1388
+
1389
+ // Download JSON
1390
+ const jsonString = JSON.stringify(exportData, null, 2);
1391
+ const blob = new Blob([jsonString], { type: 'application/json;charset=utf-8;' });
1392
+ downloadFile(blob, \`claude-session-\${currentSession.id.substring(0, 8)}.json\`);
1393
+ }
1394
+
1395
+ function downloadFile(blob, filename) {
1396
+ const link = document.createElement('a');
1397
+ const url = URL.createObjectURL(blob);
1398
+ link.setAttribute('href', url);
1399
+ link.setAttribute('download', filename);
1400
+ link.style.visibility = 'hidden';
1401
+ document.body.appendChild(link);
1402
+ link.click();
1403
+ document.body.removeChild(link);
1404
+ URL.revokeObjectURL(url);
1405
+ }
1406
+
1335
1407
  function refreshSessionDetail() {
1336
1408
  if (currentSession) {
1337
1409
  loadConversationHistory(currentSession);