@aiplumber/session-recall 1.6.0 → 1.6.6

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/session-recall +81 -55
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiplumber/session-recall",
3
- "version": "1.6.0",
3
+ "version": "1.6.6",
4
4
  "description": "Pull context from previous Claude Code sessions. Sessions end, context resets - this tool lets you continue where you left off.",
5
5
  "bin": {
6
6
  "session-recall": "./session-recall"
package/session-recall CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ const VERSION = '1.6.6';
4
+
3
5
  const fs = require('fs');
4
6
  const path = require('path');
5
7
 
@@ -1200,26 +1202,31 @@ function cmdLast(arg1, arg2, opts) {
1200
1202
  return;
1201
1203
  }
1202
1204
 
1203
- // Output combined rinse (gotime mode)
1204
- let allMsgs = selected.flatMap(s => s.msgs);
1205
- // Sort by timestamp
1206
- allMsgs.sort((a, b) => new Date(a.timestamp || 0) - new Date(b.timestamp || 0));
1205
+ // Print header
1206
+ console.log(`[session-recall v${VERSION}] This context has been stripped of most tool results to reduce noise.`);
1207
+ console.log(`---`);
1207
1208
 
1208
- // Filter by checkpoint timestamp if --after was specified
1209
- if (filterAfterTs) {
1210
- allMsgs = allMsgs.filter(msg => {
1211
- const msgTs = msg.timestamp ? new Date(msg.timestamp).getTime() : 0;
1212
- return msgTs > filterAfterTs;
1213
- });
1214
- }
1209
+ // Process each session separately to add separators
1210
+ for (let sessionIdx = 0; sessionIdx < selected.length; sessionIdx++) {
1211
+ const session = selected[sessionIdx];
1212
+ let sessionMsgs = session.msgs;
1213
+
1214
+ // Sort by timestamp
1215
+ sessionMsgs.sort((a, b) => new Date(a.timestamp || 0) - new Date(b.timestamp || 0));
1216
+
1217
+ // Filter by checkpoint timestamp if --after was specified
1218
+ if (filterAfterTs) {
1219
+ sessionMsgs = sessionMsgs.filter(msg => {
1220
+ const msgTs = msg.timestamp ? new Date(msg.timestamp).getTime() : 0;
1221
+ return msgTs > filterAfterTs;
1222
+ });
1223
+ }
1215
1224
 
1216
- // Build tool result metadata (size, duration)
1217
- const resultMeta = buildToolResultMeta(allMsgs);
1225
+ // Build tool result metadata (size, duration)
1226
+ const resultMeta = buildToolResultMeta(sessionMsgs);
1218
1227
 
1219
- // Build tag map for injection
1220
- // Tag map: { uuid -> { type, level, reason } }
1221
- const tagMap = {};
1222
- for (const session of selected) {
1228
+ // Build tag map for this session
1229
+ const tagMap = {};
1223
1230
  const sessionTags = scanSessionTags(session.filePath);
1224
1231
  for (const tag of sessionTags) {
1225
1232
  if (tag.targetUuid) {
@@ -1230,62 +1237,69 @@ function cmdLast(arg1, arg2, opts) {
1230
1237
  };
1231
1238
  }
1232
1239
  }
1233
- }
1234
1240
 
1235
- for (const msg of allMsgs) {
1236
- if (NOISE_TYPES.includes(msg.type)) continue;
1241
+ for (const msg of sessionMsgs) {
1242
+ if (NOISE_TYPES.includes(msg.type)) continue;
1237
1243
 
1238
- // Check if this message has a tag
1239
- const toolId = getToolUseId(msg);
1240
- const msgUuid = toolId || msg.uuid;
1241
- const tag = msgUuid ? tagMap[msgUuid] : null;
1244
+ // Check if this message has a tag
1245
+ const toolId = getToolUseId(msg);
1246
+ const msgUuid = toolId || msg.uuid;
1247
+ const tag = msgUuid ? tagMap[msgUuid] : null;
1242
1248
 
1243
- // Determine if we should show this tag
1244
- const showTag = tag && (
1245
- tag.level === 'critical' ||
1246
- (tag.level === 'important' && opts.showImportant)
1247
- );
1249
+ // Determine if we should show this tag
1250
+ const showTag = tag && (
1251
+ tag.level === 'critical' ||
1252
+ (tag.level === 'important' && opts.showImportant)
1253
+ );
1248
1254
 
1249
- if (msg.type === 'user') {
1250
- if (isToolResult(msg)) continue;
1251
- const text = getUserText(msg);
1252
- if (text) {
1255
+ if (msg.type === 'user') {
1256
+ if (isToolResult(msg)) continue;
1257
+ const text = getUserText(msg);
1258
+ if (text) {
1259
+ const ts = msg.timestamp ? new Date(msg.timestamp).toISOString().substring(11, 19) : '';
1260
+ if (showTag) {
1261
+ const marker = tag.level === 'critical' ? '\u26A0' : '\u2139';
1262
+ console.log(`[${ts}] ${marker} ${tag.level.toUpperCase()} [${tag.type}] USER: ${text.substring(0, 500)}`);
1263
+ console.log(` Reason: "${tag.reason}"`);
1264
+ } else {
1265
+ console.log(`[${ts}] USER: ${text.substring(0, 500)}`);
1266
+ }
1267
+ }
1268
+ } else if (msg.type === 'assistant') {
1269
+ const text = getAssistantText(msg);
1270
+ const toolSummary = collapseToolCall(msg, resultMeta);
1253
1271
  const ts = msg.timestamp ? new Date(msg.timestamp).toISOString().substring(11, 19) : '';
1272
+
1254
1273
  if (showTag) {
1255
1274
  const marker = tag.level === 'critical' ? '\u26A0' : '\u2139';
1256
- console.log(`[${ts}] ${marker} ${tag.level.toUpperCase()} [${tag.type}] USER: ${text.substring(0, 500)}`);
1275
+ if (text) {
1276
+ console.log(`[${ts}] ${marker} ${tag.level.toUpperCase()} [${tag.type}] ASSISTANT: ${text.substring(0, 500)}`);
1277
+ } else if (toolSummary) {
1278
+ console.log(`[${ts}] ${marker} ${tag.level.toUpperCase()} [${tag.type}] ${toolSummary}`);
1279
+ }
1257
1280
  console.log(` Reason: "${tag.reason}"`);
1258
1281
  } else {
1259
- console.log(`[${ts}] USER: ${text.substring(0, 500)}`);
1282
+ if (text) {
1283
+ console.log(`[${ts}] ASSISTANT: ${text.substring(0, 500)}`);
1284
+ } else if (toolSummary) {
1285
+ console.log(`[${ts}] ASSISTANT: ${toolSummary}`);
1286
+ }
1260
1287
  }
1261
1288
  }
1262
- } else if (msg.type === 'assistant') {
1263
- const text = getAssistantText(msg);
1264
- const toolSummary = collapseToolCall(msg, resultMeta);
1265
- const ts = msg.timestamp ? new Date(msg.timestamp).toISOString().substring(11, 19) : '';
1289
+ }
1266
1290
 
1267
- if (showTag) {
1268
- const marker = tag.level === 'critical' ? '\u26A0' : '\u2139';
1269
- if (text) {
1270
- console.log(`[${ts}] ${marker} ${tag.level.toUpperCase()} [${tag.type}] ASSISTANT: ${text.substring(0, 500)}`);
1271
- } else if (toolSummary) {
1272
- console.log(`[${ts}] ${marker} ${tag.level.toUpperCase()} [${tag.type}] ${toolSummary}`);
1273
- }
1274
- console.log(` Reason: "${tag.reason}"`);
1275
- } else {
1276
- if (text) {
1277
- console.log(`[${ts}] ASSISTANT: ${text.substring(0, 500)}`);
1278
- } else if (toolSummary) {
1279
- console.log(`[${ts}] ASSISTANT: ${toolSummary}`);
1280
- }
1281
- }
1291
+ // Print session separator if not the last session
1292
+ if (sessionIdx < selected.length - 1) {
1293
+ const nextSession = selected[sessionIdx + 1];
1294
+ const nextTs = nextSession.lastTs ? nextSession.lastTs.toISOString().replace('T', ' ').substring(0, 16) : 'unknown';
1295
+ console.log(`\n=== END SESSION ${sessionIdx + 1} === NEXT SESSION: ${nextSession.project} (${nextTs}) ===\n`);
1282
1296
  }
1283
1297
  }
1284
1298
 
1285
1299
  // Print instructions for Claude
1286
1300
  console.log(``);
1287
1301
  console.log(`---`);
1288
- console.log(`To get a specific tool result: session-recall tools --show <id>`);
1302
+ console.log(`Tool results: Most are noise. Only fetch with "session-recall tools --show <id>" when you see something you actually need.`);
1289
1303
  console.log(`Session file: ${selected[0]?.filePath || 'unknown'}`);
1290
1304
  }
1291
1305
 
@@ -1349,6 +1363,10 @@ TAGGING:
1349
1363
  tags [filter] List all tags in current project
1350
1364
  Filter by type or level
1351
1365
 
1366
+ OPTIONS:
1367
+ -v, --version Show version number
1368
+ -h, --help Show this help
1369
+
1352
1370
  EXAMPLES:
1353
1371
  session-recall last 1 -d # Check what's available
1354
1372
  session-recall last 1 -f text # Pull last session
@@ -1797,6 +1815,8 @@ function parseArgs(args) {
1797
1815
  opts.showImportant = true;
1798
1816
  } else if (arg === '-h' || arg === '--help') {
1799
1817
  opts.help = true;
1818
+ } else if (arg === '-v' || arg === '--version') {
1819
+ opts.version = true;
1800
1820
  } else if (!arg.startsWith('-')) {
1801
1821
  positional.push(arg);
1802
1822
  }
@@ -1810,6 +1830,12 @@ function parseArgs(args) {
1810
1830
  const args = process.argv.slice(2);
1811
1831
  const { opts, positional } = parseArgs(args);
1812
1832
 
1833
+ // Handle --version flag
1834
+ if (opts.version) {
1835
+ console.log(`session-recall v${VERSION}`);
1836
+ process.exit(0);
1837
+ }
1838
+
1813
1839
  // Handle --checkpoint flag first (no-op marker that gets logged)
1814
1840
  if (opts.checkpoint) {
1815
1841
  // Output marker format - this IS the checkpoint storage (searched in tool_result)