@claude-sessions/core 0.4.7 → 0.4.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.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as Project, M as MessagePayload$1, a as Message, S as SummaryInfo, b as SessionTodos, c as MoveSessionResult, A as AgentInfo, d as SessionSortOptions, e as ProjectTreeData, C as CompressSessionOptions, f as SummarizeSessionOptions, g as ConversationLine, h as SearchResult, F as FileChange, i as SessionsIndex, j as SessionIndexEntry } from './types-BMQErZZE.js';
2
- export { p as CleanupPreview, o as ClearSessionsResult, v as CompressSessionResult, k as ContentItem, D as DeleteSessionResult, w as ProjectKnowledge, R as RenameSessionResult, r as ResumeSessionOptions, s as ResumeSessionResult, u as SessionAnalysis, m as SessionFilesSummary, l as SessionMeta, y as SessionSortField, z as SessionSortOrder, q as SessionTreeData, n as SplitSessionResult, x as SummarizeSessionResult, T as TodoItem, t as ToolUsageStats } from './types-BMQErZZE.js';
1
+ import { P as Project, M as MessagePayload$1, a as Message, T as TitleDisplayMode, S as SummaryInfo, b as SessionSortField, c as SessionTodos, d as MoveSessionResult, A as AgentInfo, e as SessionSortOptions, f as ProjectTreeData, C as CompressSessionOptions, g as SummarizeSessionOptions, h as ConversationLine, i as SearchResult, F as FileChange, j as SessionsIndex, k as SessionIndexEntry } from './types-AvikAHId.js';
2
+ export { r as CleanupPreview, q as ClearSessionsResult, x as CompressSessionResult, l as ContentItem, D as DeleteSessionResult, y as ProjectKnowledge, R as RenameSessionResult, t as ResumeSessionOptions, u as ResumeSessionResult, w as SessionAnalysis, o as SessionFilesSummary, m as SessionMeta, B as SessionSortOrder, s as SessionTreeData, p as SplitSessionResult, z as SummarizeSessionResult, n as TodoItem, v as ToolUsageStats } from './types-AvikAHId.js';
3
3
  import * as effect_Cause from 'effect/Cause';
4
4
  import { Effect } from 'effect';
5
5
 
@@ -94,25 +94,60 @@ declare const parseCommandMessage: (content?: string) => {
94
94
  declare const extractTitle: (input: MessagePayload$1 | string | undefined) => string;
95
95
  declare const isInvalidApiKeyMessage: (msg: Message) => boolean;
96
96
  declare const isContinuationSummary: (msg: Message) => boolean;
97
+ /**
98
+ * Options for getDisplayTitle when using the options-based signature
99
+ */
100
+ interface DisplayTitleOptions {
101
+ customTitle?: string;
102
+ currentSummary?: string;
103
+ title?: string;
104
+ createdAt?: string;
105
+ maxLength?: number;
106
+ fallback?: string;
107
+ /** 'message' = first user message (default), 'datetime' = relative date/time */
108
+ mode?: TitleDisplayMode;
109
+ /** Locale for date formatting (e.g. 'de-DE', 'en-GB'). Defaults to system locale. */
110
+ locale?: string;
111
+ }
97
112
  /**
98
113
  * Get display title with fallback logic
99
- * Priority: customTitle > currentSummary (truncated) > title > fallback
114
+ * Priority: customTitle > currentSummary (truncated) > title/datetime > fallback
100
115
  * Also handles slash command format in title
116
+ *
117
+ * Supports two call signatures:
118
+ * - Legacy: getDisplayTitle(customTitle, currentSummary, title, maxLength?, fallback?)
119
+ * - Options: getDisplayTitle(options)
101
120
  */
102
- declare const getDisplayTitle: (customTitle: string | undefined, currentSummary: string | undefined, title: string | undefined, maxLength?: number, fallback?: string) => string;
121
+ declare function getDisplayTitle(options: DisplayTitleOptions): string;
122
+ declare function getDisplayTitle(customTitle: string | undefined, currentSummary: string | undefined, title: string | undefined, maxLength?: number, fallback?: string): string;
103
123
  /**
104
124
  * Mask home directory path with ~
105
125
  * Only masks the specified homeDir, not other users' paths
106
126
  */
107
127
  declare const maskHomePath: (text: string, homeDir: string) => string;
108
128
  /**
109
- * Get sort timestamp for session (Unix timestamp ms)
110
- * Priority: summaries[0].timestamp > createdAt > 0
129
+ * Get summary-based sort timestamp for session (Unix timestamp ms)
130
+ * Used for 'summary' sort field. Priority: summaries[0].timestamp > createdAt > 0
111
131
  */
132
+ declare const getSummarySortTimestamp: (session: {
133
+ summaries?: SummaryInfo[];
134
+ createdAt?: string;
135
+ }) => number;
136
+ /** @deprecated Use getSummarySortTimestamp instead */
112
137
  declare const getSessionSortTimestamp: (session: {
113
138
  summaries?: SummaryInfo[];
114
139
  createdAt?: string;
115
140
  }) => number;
141
+ /**
142
+ * Get display-ready sort timestamp based on active sort field.
143
+ * Returns the timestamp matching what the user sees as the sort order.
144
+ */
145
+ declare const getDisplaySortTimestamp: (session: {
146
+ summaries?: SummaryInfo[];
147
+ createdAt?: string;
148
+ updatedAt?: string;
149
+ fileMtime?: number;
150
+ }, sortField: SessionSortField) => number;
116
151
  /**
117
152
  * Try to parse a single JSON line, returning null on failure with optional warning log
118
153
  * Use this when you want to skip invalid lines instead of throwing
@@ -139,7 +174,7 @@ declare const readJsonlFile: <T = Record<string, unknown>>(filePath: string, opt
139
174
  * @param timestamp - Unix timestamp (ms) or ISO date string
140
175
  * @returns Relative time string
141
176
  */
142
- declare const formatRelativeTime: (timestamp: number | string) => string;
177
+ declare const formatRelativeTime: (timestamp: number | string, locale?: string) => string;
143
178
  /**
144
179
  * Calculate total todo count from session todos
145
180
  * Includes both session-level and agent-level todos
@@ -670,4 +705,4 @@ declare const getLogger: () => Logger;
670
705
  */
671
706
  declare const createLogger: (namespace: string) => Logger;
672
707
 
673
- export { AgentInfo, type ChainError, CompressSessionOptions, ConversationLine, FileChange, type GenericMessage, type Logger, Message, MessagePayload$1 as MessagePayload, MoveSessionResult, type ProgressError, Project, ProjectTreeData, SearchResult, SessionIndexEntry, SessionSortOptions, SessionTodos, SessionsIndex, SummarizeSessionOptions, SummaryInfo, TREE_ICONS, type ToolUseResultError, type TreeItemType, type ValidationResult, analyzeSession, autoRepairChain, canMoveSession, clearSessions, compressSession, createLogger, deleteLinkedTodos, deleteMessage, deleteMessageWithChainRepair, deleteOrphanAgents, deleteOrphanTodos, deleteSession, expandHomePath, extractProjectKnowledge, extractTextContent, extractTitle, findLinkedAgents, findLinkedTodos, findOrphanAgents, findOrphanTodos, findProjectByWorkspacePath, folderNameToDisplayPath, folderNameToPath, formatRelativeTime, generateTreeNodeId, getCachePath, getDisplayTitle, getIndexEntryDisplayTitle, getLogger, getRealPathFromSession, getSessionFiles, getSessionSortTimestamp, getSessionTooltip, getSessionsDir, getTodoIcon, getTodosDir, getTotalTodoCount, hasSessionsIndex, isContinuationSummary, isInvalidApiKeyMessage, listProjects, listSessions, loadAgentMessages, loadProjectTreeData, loadSessionTreeData, loadSessionsIndex, maskHomePath, moveSession, parseCommandMessage, parseJsonlLines, parseTreeNodeId, pathToFolderName, previewCleanup, readJsonlFile, readSession, renameSession, repairChain, repairParentUuidChain, restoreMessage, searchSessions, sessionHasSubItems, sessionHasTodos, setLogger, sortIndexEntriesByModified, sortProjects, splitSession, summarizeSession, tryParseJsonLine, updateSessionSummary, validateChain, validateProgressMessages, validateToolUseResult };
708
+ export { AgentInfo, type ChainError, CompressSessionOptions, ConversationLine, type DisplayTitleOptions, FileChange, type GenericMessage, type Logger, Message, MessagePayload$1 as MessagePayload, MoveSessionResult, type ProgressError, Project, ProjectTreeData, SearchResult, SessionIndexEntry, SessionSortField, SessionSortOptions, SessionTodos, SessionsIndex, SummarizeSessionOptions, SummaryInfo, TREE_ICONS, TitleDisplayMode, type ToolUseResultError, type TreeItemType, type ValidationResult, analyzeSession, autoRepairChain, canMoveSession, clearSessions, compressSession, createLogger, deleteLinkedTodos, deleteMessage, deleteMessageWithChainRepair, deleteOrphanAgents, deleteOrphanTodos, deleteSession, expandHomePath, extractProjectKnowledge, extractTextContent, extractTitle, findLinkedAgents, findLinkedTodos, findOrphanAgents, findOrphanTodos, findProjectByWorkspacePath, folderNameToDisplayPath, folderNameToPath, formatRelativeTime, generateTreeNodeId, getCachePath, getDisplaySortTimestamp, getDisplayTitle, getIndexEntryDisplayTitle, getLogger, getRealPathFromSession, getSessionFiles, getSessionSortTimestamp, getSessionTooltip, getSessionsDir, getSummarySortTimestamp, getTodoIcon, getTodosDir, getTotalTodoCount, hasSessionsIndex, isContinuationSummary, isInvalidApiKeyMessage, listProjects, listSessions, loadAgentMessages, loadProjectTreeData, loadSessionTreeData, loadSessionsIndex, maskHomePath, moveSession, parseCommandMessage, parseJsonlLines, parseTreeNodeId, pathToFolderName, previewCleanup, readJsonlFile, readSession, renameSession, repairChain, repairParentUuidChain, restoreMessage, searchSessions, sessionHasSubItems, sessionHasTodos, setLogger, sortIndexEntriesByModified, sortProjects, splitSession, summarizeSession, tryParseJsonLine, updateSessionSummary, validateChain, validateProgressMessages, validateToolUseResult };
package/dist/index.js CHANGED
@@ -95,11 +95,31 @@ var isContinuationSummary = (msg) => {
95
95
  const text = extractTextContent(msg.message);
96
96
  return text.startsWith("This session is being continued from");
97
97
  };
98
- var getDisplayTitle = (customTitle, currentSummary, title, maxLength = 60, fallback = "Untitled") => {
98
+ function getDisplayTitle(customTitleOrOptions, currentSummary, title, maxLength = 60, fallback = "Untitled") {
99
+ let mode = "message";
100
+ let createdAt;
101
+ let customTitle;
102
+ let locale;
103
+ if (typeof customTitleOrOptions === "object" && customTitleOrOptions !== null) {
104
+ const opts = customTitleOrOptions;
105
+ customTitle = opts.customTitle;
106
+ currentSummary = opts.currentSummary;
107
+ title = opts.title;
108
+ createdAt = opts.createdAt;
109
+ maxLength = opts.maxLength ?? 60;
110
+ fallback = opts.fallback ?? "Untitled";
111
+ mode = opts.mode ?? "message";
112
+ locale = opts.locale;
113
+ } else {
114
+ customTitle = customTitleOrOptions;
115
+ }
99
116
  if (customTitle) return customTitle;
100
117
  if (currentSummary) {
101
118
  return currentSummary.length > maxLength ? currentSummary.slice(0, maxLength - 3) + "..." : currentSummary;
102
119
  }
120
+ if (mode === "datetime" && createdAt) {
121
+ return formatRelativeTime(createdAt, locale);
122
+ }
103
123
  if (title && title !== "Untitled") {
104
124
  const firstParagraph = title.includes("\n\n") ? title.split("\n\n")[0] : title;
105
125
  if (firstParagraph.includes("<command-name>")) {
@@ -109,7 +129,7 @@ var getDisplayTitle = (customTitle, currentSummary, title, maxLength = 60, fallb
109
129
  return firstParagraph;
110
130
  }
111
131
  return fallback;
112
- };
132
+ }
113
133
  var replaceMessageContent = (msg, text) => ({
114
134
  ...msg,
115
135
  message: {
@@ -143,10 +163,27 @@ var maskHomePath = (text, homeDir) => {
143
163
  const regex = new RegExp(`${escapedHome}(?=[/\\\\]|$)`, "g");
144
164
  return text.replace(regex, "~");
145
165
  };
146
- var getSessionSortTimestamp = (session) => {
166
+ var getSummarySortTimestamp = (session) => {
147
167
  const timestampStr = session.summaries?.[0]?.timestamp ?? session.createdAt;
148
168
  return timestampStr ? new Date(timestampStr).getTime() : 0;
149
169
  };
170
+ var getSessionSortTimestamp = getSummarySortTimestamp;
171
+ var getDisplaySortTimestamp = (session, sortField) => {
172
+ switch (sortField) {
173
+ case "updated": {
174
+ if (session.updatedAt) return new Date(session.updatedAt).getTime();
175
+ return getSummarySortTimestamp(session);
176
+ }
177
+ case "created": {
178
+ if (session.createdAt) return new Date(session.createdAt).getTime();
179
+ return getSummarySortTimestamp(session);
180
+ }
181
+ case "modified":
182
+ return session.fileMtime ?? getSummarySortTimestamp(session);
183
+ default:
184
+ return getSummarySortTimestamp(session);
185
+ }
186
+ };
150
187
  var tryParseJsonLine = (line, lineNumber, filePath) => {
151
188
  try {
152
189
  return JSON.parse(line);
@@ -179,7 +216,7 @@ var readJsonlFile = (filePath, options) => Effect.gen(function* () {
179
216
  const lines = content.trim().split("\n").filter(Boolean);
180
217
  return parseJsonlLines(lines, filePath, options);
181
218
  });
182
- var formatRelativeTime = (timestamp) => {
219
+ var formatRelativeTime = (timestamp, locale) => {
183
220
  const date = typeof timestamp === "string" ? new Date(timestamp) : new Date(timestamp);
184
221
  const now = /* @__PURE__ */ new Date();
185
222
  const diff = now.getTime() - date.getTime();
@@ -190,7 +227,7 @@ var formatRelativeTime = (timestamp) => {
190
227
  if (minutes < 60) return `${minutes}m ago`;
191
228
  if (hours < 24) return `${hours}h ago`;
192
229
  if (days < 7) return `${days}d ago`;
193
- return date.toLocaleDateString();
230
+ return date.toLocaleDateString(locale, { day: "numeric", month: "short", year: "numeric" });
194
231
  };
195
232
  var getTotalTodoCount = (todos) => {
196
233
  return todos.sessionTodos.length + todos.agentTodos.reduce((sum, a) => sum + a.todos.length, 0);
@@ -1590,7 +1627,7 @@ var loadSessionTreeDataInternal = (projectName, sessionId, summariesByTargetSess
1590
1627
  }
1591
1628
  const todos = yield* findLinkedTodos(sessionId, linkedAgentIds);
1592
1629
  const createdAt = firstMessage?.timestamp ?? void 0;
1593
- const sortTimestamp = getSessionSortTimestamp({ summaries, createdAt });
1630
+ const sortTimestamp = getSummarySortTimestamp({ summaries, createdAt });
1594
1631
  return {
1595
1632
  id: sessionId,
1596
1633
  projectName,
@@ -1689,12 +1726,16 @@ var buildProjectTreeResult = (project, sessions, sort) => {
1689
1726
  if (isErrorSessionTitle(s.currentSummary)) return false;
1690
1727
  return true;
1691
1728
  });
1729
+ const displaySessions = filteredSessions.map((s) => ({
1730
+ ...s,
1731
+ sortTimestamp: getDisplaySortTimestamp(s, sort.field)
1732
+ }));
1692
1733
  return {
1693
1734
  name: project.name,
1694
1735
  displayName: project.displayName,
1695
1736
  path: project.path,
1696
- sessionCount: filteredSessions.length,
1697
- sessions: filteredSessions
1737
+ sessionCount: displaySessions.length,
1738
+ sessions: displaySessions
1698
1739
  };
1699
1740
  };
1700
1741
  var buildTreeCache = (globalUuidMap, allSummaries, sessions, fileMtimes) => {
@@ -1721,7 +1762,7 @@ var updateSessionSummaries = (cached, summariesByTargetSession) => {
1721
1762
  const oldJson = JSON.stringify(cached.summaries);
1722
1763
  const newJson = JSON.stringify(newSummaries);
1723
1764
  if (oldJson === newJson) return cached;
1724
- const newSortTimestamp = getSessionSortTimestamp({
1765
+ const newSortTimestamp = getSummarySortTimestamp({
1725
1766
  summaries: newSummaries,
1726
1767
  createdAt: cached.createdAt
1727
1768
  });
@@ -2575,6 +2616,7 @@ export {
2575
2616
  formatRelativeTime,
2576
2617
  generateTreeNodeId,
2577
2618
  getCachePath,
2619
+ getDisplaySortTimestamp,
2578
2620
  getDisplayTitle,
2579
2621
  getIndexEntryDisplayTitle,
2580
2622
  getLogger,
@@ -2583,6 +2625,7 @@ export {
2583
2625
  getSessionSortTimestamp,
2584
2626
  getSessionTooltip,
2585
2627
  getSessionsDir,
2628
+ getSummarySortTimestamp,
2586
2629
  getTodoIcon,
2587
2630
  getTodosDir,
2588
2631
  getTotalTodoCount,