@@ -1347,7 +1347,7 @@ function showDetail(span) {
13471347 setTimeout(function() { toast.classList.remove('show'); }, 2500);
13481348 }
13491349
1350- // Build markdown summary
1350+ // Build markdown summary — self-contained, doesn't depend on Summary IIFE variables
13511351 function buildMarkdownSummary() {
13521352 var s = t.summary || {};
13531353 var title = t.metadata.title || t.sessionId || 'Session';
@@ -1358,41 +1358,54 @@ function showDetail(span) {
13581358
13591359 // Prompt
13601360 if (t.metadata.prompt) {
1361+ var promptLine = t.metadata.prompt.replace(/^["']+|["']+$/g, '').replace(/^#+\\s*/gm, '').trim().split('\\n').filter(function(l) { return l.trim().length > 5; })[0] || '';
13611362 lines.push('### What was asked');
1362- lines.push('> ' + t.metadata.prompt.split('\\n')[0] .slice(0, 200));
1363+ lines.push('> ' + promptLine .slice(0, 200));
13631364 lines.push('');
13641365 }
13651366
1366- // Files changed
1367- var changedKeys = Object.keys(changedFiles);
1368- if (changedKeys.length > 0) {
1369- lines.push('### Files changed');
1370- changedKeys.forEach(function(fp) {
1371- lines.push('- \\x60' + shortPath(fp) + '\\x60 (' + (changedFiles[fp] === 'write' ? 'new' : 'edited') + ')');
1372- });
1373- lines.push('');
1374- }
1367+ // Compute files from spans (independent of Summary IIFE)
1368+ var mdChanged = {};
1369+ var mdReadCount = 0;
1370+ var mdDbtCount = 0;
1371+ var mdSqlCount = 0;
1372+ var mdErrCount = 0;
1373+ var mdCmdCount = 0;
1374+ nonSession.forEach(function(sp) {
1375+ if (sp.kind !== 'tool') { if (sp.status === 'error') mdErrCount++; return; }
1376+ var nm = (sp.name || '').toLowerCase();
1377+ var inp = (sp.input && typeof sp.input === 'object') ? sp.input : {};
1378+ var fp = inp.file_path || inp.filePath || inp.path || null;
1379+ if (nm.indexOf('write') >= 0 || nm.indexOf('edit') >= 0) { if (fp) mdChanged[fp] = nm.indexOf('write') >= 0 ? 'new' : 'edited'; }
1380+ else if (nm.indexOf('read') >= 0) { mdReadCount++; }
1381+ else if (nm === 'bash') {
1382+ var cmd = inp.command || '';
1383+ var parts = cmd.split(/\\s*&&\\s*/);
1384+ var last = parts[parts.length - 1].trim().toLowerCase();
1385+ if (/\\bdbt\\s+/.test(last)) mdDbtCount++;
1386+ else if (!/^(ls|cd|cat|head|tail|echo|pwd|which|wc|file|mkdir|test|find|stat)\\b/.test(last)) mdCmdCount++;
1387+ }
1388+ else if (nm.indexOf('sql') >= 0) mdSqlCount++;
1389+ if (sp.status === 'error') mdErrCount++;
1390+ });
13751391
1376- // Outcome
1377- if (cmdOutcomes.length > 0) {
1378- lines.push('### Outcome');
1379- cmdOutcomes.forEach(function(o) {
1380- lines.push('- ' + (o.status === 'error' ? '\\u274C ' : '\\u2705 ') + o.command + ': ' + o.result);
1392+ var mdChangedKeys = Object.keys(mdChanged);
1393+ if (mdChangedKeys.length > 0) {
1394+ lines.push('### Files changed');
1395+ mdChangedKeys.forEach(function(fp) {
1396+ var short = fp.split('/').slice(-3).join('/');
1397+ lines.push('- ' + short + ' (' + mdChanged[fp] + ')');
13811398 });
13821399 lines.push('');
13831400 }
13841401
1385- // What happened
13861402 lines.push('### What happened');
1387- var readCount = Object.keys(readFiles).length;
1388- if (readCount > 0) lines.push('- Read ' + readCount + ' files for context');
1389- if (changedKeys.length > 0) lines.push('- Modified ' + changedKeys.length + ' file(s)');
1390- if (dbtOps.length > 0) lines.push('- Ran ' + dbtOps.length + ' dbt command(s)');
1391- if (sqlQueries.length > 0) lines.push('- Executed ' + sqlQueries.length + ' SQL query/queries');
1392- var meaningfulBash = bashCmds.filter(function(c) { if (c.isDbt) return false; var d = (c.displayCommand || c.command).trim().toLowerCase(); return !/^(ls|cd|cat|head|tail|echo|pwd|which|wc|file|mkdir|test|find|stat)\\b/.test(d); });
1393- if (meaningfulBash.length > 0) lines.push('- Ran ' + meaningfulBash.length + ' shell command(s)');
1394- var errCount = nonSession.filter(function(sp) { return sp.status === 'error'; }).length;
1395- if (errCount > 0) lines.push('- ' + errCount + ' error(s) encountered');
1403+ if (mdReadCount > 0) lines.push('- Read ' + mdReadCount + ' files for context');
1404+ if (mdChangedKeys.length > 0) lines.push('- Modified ' + mdChangedKeys.length + ' file(s)');
1405+ if (mdDbtCount > 0) lines.push('- Ran ' + mdDbtCount + ' dbt command(s)');
1406+ if (mdSqlCount > 0) lines.push('- Executed ' + mdSqlCount + ' SQL query/queries');
1407+ if (mdCmdCount > 0) lines.push('- Ran ' + mdCmdCount + ' shell command(s)');
1408+ if (mdErrCount > 0) lines.push('- ' + mdErrCount + ' error(s) encountered');
13961409 lines.push('');
13971410 lines.push('---');
13981411 lines.push('_Generated with [Altimate Code](https://altimate.ai/recap)_');
0 commit comments