MCPcopy Create free account
hub / github.com/Eversmile12/sharedcontext / listConversationsCommand

Function listConversationsCommand

src/cli/list.ts:34–72  ·  view source on GitHub ↗
(
  options: ListConversationsOptions
)

Source from the content-addressed store, hash-verified

32}
33
34export async function listConversationsCommand(
35 options: ListConversationsOptions
36): Promise<void> {
37 const allConversations = await discoverConversations({ localOnly: options.localOnly });
38
39 const clientFilter = options.client ?? "any";
40 const projectFilter = options.project?.trim().toLowerCase();
41 const requestedLimit = Number.parseInt(options.limit ?? "30", 10);
42 const limit = Number.isFinite(requestedLimit) && requestedLimit > 0 ? requestedLimit : 30;
43
44 const items = allConversations
45 .filter((conversation) => {
46 if (clientFilter !== "any" && conversation.client !== clientFilter) return false;
47 if (projectFilter && conversation.project.toLowerCase() !== projectFilter) return false;
48 return true;
49 })
50 .sort((a, b) => b.updatedAt.localeCompare(a.updatedAt))
51 .slice(0, limit);
52
53 if (items.length === 0) {
54 console.log("No conversations found.");
55 return;
56 }
57
58 console.log(
59 "Conversations (use the ID with future share commands):\n"
60 );
61 for (const conversation of items) {
62 const preview = getPreview(conversation);
63 console.log(`- ID: ${conversation.id}`);
64 console.log(` Client: ${conversation.client}`);
65 console.log(` Project: ${conversation.project}`);
66 console.log(` Updated: ${conversation.updatedAt}`);
67 console.log(` Msgs: ${conversation.messages.length}`);
68 console.log(` Source: ${conversation.source}`);
69 if (preview) console.log(` Preview: ${preview}`);
70 console.log();
71 }
72}
73
74export function listContextCommand(options: ListContextOptions): void {
75 const dbPath = ensureInitialized();

Callers 1

index.tsFile · 0.85

Calls 2

discoverConversationsFunction · 0.85
getPreviewFunction · 0.85

Tested by

no test coverage detected