@yugenlab/vaayu 0.1.9 → 0.1.11

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 (43) hide show
  1. package/chunks/{agentic-tool-loop-2FZK72JO.js → agentic-tool-loop-O3NUV7KG.js} +1 -1
  2. package/chunks/{chunk-UZ6OIVEC.js → chunk-2OBLQJYJ.js} +1 -1
  3. package/chunks/{chunk-PJEYJQ2C.js → chunk-3AYSJ7WB.js} +30 -18
  4. package/chunks/{chunk-U62ABYKD.js → chunk-67DXWEKG.js} +3 -3
  5. package/chunks/{chunk-6556EKOB.js → chunk-7AYYXHYZ.js} +25 -24
  6. package/chunks/{chunk-IGBRBFXX.js → chunk-7XV5ISV7.js} +7 -5
  7. package/chunks/{chunk-JAWZ7ANC.js → chunk-A3HOZBC5.js} +11 -7
  8. package/chunks/{chunk-LVE2EOOH.js → chunk-D46QTN3G.js} +126 -136
  9. package/chunks/{chunk-PRXQW76U.js → chunk-EG37M4QL.js} +17 -6
  10. package/chunks/{chunk-7UOXFHEB.js → chunk-F6RNEGFX.js} +480 -432
  11. package/chunks/{chunk-MJ74G5RB.js → chunk-G2QREGXK.js} +2 -2
  12. package/chunks/{chunk-DOQMEQ5S.js → chunk-JZTFJE7M.js} +39 -39
  13. package/chunks/{chunk-S2HDNNC7.js → chunk-LJUEMPLG.js} +638 -679
  14. package/chunks/{chunk-C76USAC5.js → chunk-QFGAB4XD.js} +13 -5
  15. package/chunks/{chunk-D3RVJGO7.js → chunk-QV4GPIPT.js} +118 -135
  16. package/chunks/{chunk-YJRXLRTE.js → chunk-V2ZIKDN4.js} +9 -8
  17. package/chunks/{chunk-YSC77CKZ.js → chunk-VCUJES75.js} +3276 -3526
  18. package/chunks/{chunk-OBYBBGHA.js → chunk-W4PVGBUH.js} +190 -189
  19. package/chunks/chunk-Z576WVLG.js +434 -0
  20. package/chunks/{chunk-NHRBVSN3.js → chunk-ZYY6N3SP.js} +117 -110
  21. package/chunks/{consolidation-indexer-CD6DS2HO.js → consolidation-indexer-VIWOP6VO.js} +8 -8
  22. package/chunks/{day-consolidation-U3X6P4ZG.js → day-consolidation-HMHSXIOM.js} +8 -4
  23. package/chunks/{src-ZAKUL232.js → dist-CY5NX2IK.js} +17 -17
  24. package/chunks/graphrag-T2QWNX57.js +14 -0
  25. package/chunks/{hierarchical-temporal-search-ETXYYJZK.js → hierarchical-temporal-search-U6DG74IR.js} +2 -2
  26. package/chunks/hybrid-search-BYTXCOXP.js +20 -0
  27. package/chunks/{memory-store-A6WOWLWC.js → memory-store-LEERUQGL.js} +3 -3
  28. package/chunks/periodic-consolidation-D6SSKZ7H.js +11 -0
  29. package/chunks/{postgres-WLH3D5HG.js → postgres-7GZDDX77.js} +2 -2
  30. package/chunks/{recall-IUPQCBYP.js → recall-LNRQVATQ.js} +7 -7
  31. package/chunks/search-BIODUW2P.js +19 -0
  32. package/chunks/{session-store-NDUDYAC7.js → session-store-O3TS7DUY.js} +5 -5
  33. package/chunks/{sqlite-DHUQGPR5.js → sqlite-7BC4DJTN.js} +2 -2
  34. package/chunks/vasana-engine-BJFHJVGM.js +30 -0
  35. package/gateway.js +31671 -24786
  36. package/package.json +1 -1
  37. package/pair-cli.js +1 -1
  38. package/chunks/chunk-TEQKXGIK.js +0 -752
  39. package/chunks/graphrag-LAZSXLLI.js +0 -14
  40. package/chunks/hybrid-search-TX6T3KYH.js +0 -20
  41. package/chunks/periodic-consolidation-4MACZE6S.js +0 -11
  42. package/chunks/search-HHSVHBXC.js +0 -19
  43. package/chunks/vasana-engine-G6BPOFX7.js +0 -10
@@ -2,69 +2,17 @@ import {
2
2
  EmbeddingService,
3
3
  cosineSimilarity,
4
4
  fallbackEmbedding
5
- } from "./chunk-JAWZ7ANC.js";
5
+ } from "./chunk-A3HOZBC5.js";
6
6
  import {
7
7
  SessionError,
8
8
  getChitraguptaHome
9
- } from "./chunk-UZ6OIVEC.js";
9
+ } from "./chunk-2OBLQJYJ.js";
10
10
 
11
- // ../chitragupta/packages/smriti/src/day-consolidation.ts
12
- import fs from "fs";
13
- import path from "path";
11
+ // ../chitragupta/packages/smriti/dist/day-consolidation.js
12
+ import fs2 from "fs";
13
+ import path2 from "path";
14
14
 
15
- // ../chitragupta/packages/smriti/src/event-extractor.ts
16
- var DOMAIN_SIGNALS = {
17
- planning: [
18
- /\b(?:plan for|roadmap|milestone|timeline|schedule|deadline|sprint|backlog|prioriti[sz]e)\b/i,
19
- /\b(?:next steps|action items|todo list|to-do list|project plan|gantt|kanban)\b/i,
20
- /\b(?:due date|estimated time|target date|delivery date|eta for)\b/i
21
- ],
22
- learning: [
23
- /\b(?:teach me|learn about|learn how|tutorial|take a course|study for)\b/i,
24
- /\b(?:explain to me|help me understand|walkthrough|lesson on)\b/i,
25
- /\b(?:what is a|what are the|concept of|fundamentals of|theory behind)\b/i
26
- ],
27
- creative: [
28
- /\b(?:write a|draft a|compose a|brainstorm|ideate|creative writing|story about|poem|essay|blog post)\b/i,
29
- /\b(?:sketch a|mockup|wireframe|logo for|brand identity)\b/i,
30
- /\b(?:name suggestions|tagline|slogan|elevator pitch)\b/i
31
- ],
32
- operational: [
33
- /\b(?:deploy to|release to|rollback|rollout|uptime|downtime|incident)\b/i,
34
- /\b(?:docker|kubernetes|k8s|nginx|systemd|terraform|ansible)\b/i,
35
- /\b(?:infrastructure|ci\/cd pipeline|staging|production environment)\b/i
36
- ],
37
- research: [
38
- /\b(?:research on|investigate|deep dive|literature review|state of the art|sota)\b/i,
39
- /\b(?:arxiv|paper on|survey of|systematic review|meta-analysis)\b/i,
40
- /\b(?:pros and cons|tradeoffs? between|trade-offs? between|compare .+ vs)\b/i
41
- ],
42
- health: [
43
- /\b(?:health|wellness|fitness|exercise routine|workout|diet plan|nutrition|calories)\b/i,
44
- /\b(?:sleep schedule|meditation|mindfulness|mental health|therapy session)\b/i,
45
- /\b(?:doctor appointment|symptoms of|medicine|prescription|blood pressure)\b/i
46
- ],
47
- social: [
48
- /\b(?:send a message|reply to|draft an email|write an email|schedule a meeting)\b/i,
49
- /\b(?:birthday|anniversary|gift for|party for|event planning|gathering)\b/i,
50
- /\b(?:my friend|my family|my colleague|my partner|my wife|my husband)\b/i
51
- ],
52
- finance: [
53
- /\b(?:budget for|monthly expenses|income|salary|payment for|invoice)\b/i,
54
- /\b(?:invest in|stock|portfolio|crypto|savings account|retirement|tax return)\b/i,
55
- /\b(?:how much does|subscription|billing|net worth|financial)\b/i
56
- ],
57
- reflection: [
58
- /\b(?:reflect on|journal entry|diary entry|retrospective|look back on)\b/i,
59
- /\b(?:what went well|what could improve|lessons learned|takeaways from)\b/i,
60
- /\b(?:grateful for|gratitude|how am i doing|self-assessment)\b/i
61
- ],
62
- security: [
63
- /\b(?:security audit|vulnerability|exploit|threat model|attack vector|data breach)\b/i,
64
- /\b(?:encrypt|decrypt|ssl certificate|tls|oauth|authentication flow)\b/i,
65
- /\b(?:access control|firewall rule|security compliance|penetration test|pentest)\b/i
66
- ]
67
- };
15
+ // ../chitragupta/packages/smriti/dist/event-extractor-strategies.js
68
16
  var DOMAIN_EXTRACTOR_MAP = {
69
17
  planning: "discussion",
70
18
  learning: "discussion",
@@ -77,120 +25,12 @@ var DOMAIN_EXTRACTOR_MAP = {
77
25
  reflection: "discussion",
78
26
  security: "mixed"
79
27
  };
80
- function scoreDomainSignals(turns) {
81
- const scores = /* @__PURE__ */ new Map();
82
- const userContent = turns.filter((t) => t.role === "user").map((t) => t.content).join(" ");
83
- for (const [domain, patterns] of Object.entries(DOMAIN_SIGNALS)) {
84
- let groupsMatched = 0;
85
- for (const pattern of patterns) {
86
- if (new RegExp(pattern.source, "i").test(userContent)) {
87
- groupsMatched++;
88
- }
89
- }
90
- if (groupsMatched > 0) scores.set(domain, groupsMatched);
91
- }
92
- return scores;
93
- }
94
- function detectSessionType(turns) {
95
- if (turns.length === 0) return "personal";
96
- let toolTurns = 0;
97
- let textTurns = 0;
98
- let totalUserLength = 0;
99
- let userTurnCount = 0;
100
- for (const turn of turns) {
101
- const hasToolCall = /\[tool:\w+\]/.test(turn.content) || turn.toolCalls && turn.toolCalls.length > 0;
102
- if (hasToolCall) {
103
- toolTurns++;
104
- } else {
105
- textTurns++;
106
- }
107
- if (turn.role === "user") {
108
- totalUserLength += turn.content.length;
109
- userTurnCount++;
110
- }
111
- }
112
- const avgUserLength = userTurnCount > 0 ? totalUserLength / userTurnCount : 0;
113
- const toolRatio = turns.length > 0 ? toolTurns / turns.length : 0;
114
- let coreType;
115
- if (turns.length <= 4 && avgUserLength < 100) {
116
- coreType = "personal";
117
- } else if (toolRatio > 0.6) {
118
- coreType = "coding";
119
- } else if (toolRatio < 0.15) {
120
- coreType = "discussion";
121
- } else {
122
- coreType = "mixed";
123
- }
124
- if (coreType === "coding") return "coding";
125
- const domainScores = scoreDomainSignals(turns);
126
- if (domainScores.size === 0) return coreType;
127
- let topDomain = null;
128
- let topScore = 0;
129
- for (const [domain, score] of domainScores) {
130
- if (score > topScore) {
131
- topScore = score;
132
- topDomain = domain;
133
- }
134
- }
135
- if (topDomain && topScore >= 2) {
136
- return topDomain;
137
- }
138
- return coreType;
139
- }
140
28
  function getExtractorStrategy(sessionType) {
141
29
  if (sessionType === "coding" || sessionType === "discussion" || sessionType === "mixed" || sessionType === "personal") {
142
30
  return sessionType;
143
31
  }
144
32
  return DOMAIN_EXTRACTOR_MAP[sessionType];
145
33
  }
146
- function extractEventChain(meta, turns) {
147
- const sessionType = detectSessionType(turns);
148
- const provider = meta.provider ?? meta.metadata?.provider ?? meta.agent ?? "unknown";
149
- const events = [];
150
- const topics = [];
151
- const strategy = getExtractorStrategy(sessionType);
152
- for (let i = 0; i < turns.length; i++) {
153
- const turn = turns[i];
154
- const timestamp = turn.createdAt;
155
- if (turn.role === "user") {
156
- const userEvents = extractFromUserTurn(turn, timestamp, meta.id, provider);
157
- events.push(...userEvents);
158
- const topic = extractTopic(turn.content);
159
- if (topic && !topics.includes(topic)) {
160
- topics.push(topic);
161
- }
162
- } else if (turn.role === "assistant") {
163
- switch (strategy) {
164
- case "coding":
165
- events.push(...extractFromCodingAssistant(turn, timestamp, meta.id, provider));
166
- break;
167
- case "discussion":
168
- events.push(...extractFromDiscussionAssistant(turn, timestamp, meta.id, provider));
169
- break;
170
- case "mixed":
171
- events.push(...extractFromCodingAssistant(turn, timestamp, meta.id, provider));
172
- events.push(...extractFromDiscussionAssistant(turn, timestamp, meta.id, provider));
173
- break;
174
- case "personal":
175
- if (turn.content.length < 500) {
176
- events.push({
177
- type: "action",
178
- summary: turn.content.split("\n")[0].slice(0, 200),
179
- timestamp,
180
- sessionId: meta.id,
181
- provider,
182
- turnNumber: turn.turnNumber
183
- });
184
- }
185
- break;
186
- }
187
- }
188
- }
189
- const deduped = deduplicateEvents(events);
190
- deduped.sort((a, b) => a.timestamp - b.timestamp);
191
- const narrative = generateNarrative(sessionType, deduped, meta, provider);
192
- return { sessionType, events: deduped, narrative, topics, meta };
193
- }
194
34
  function extractFromUserTurn(turn, timestamp, sessionId, provider) {
195
35
  const events = [];
196
36
  const content = turn.content.trim();
@@ -331,9 +171,7 @@ function extractFromDiscussionAssistant(turn, timestamp, sessionId, provider) {
331
171
  });
332
172
  }
333
173
  }
334
- const optionLines = lines.filter(
335
- (l) => /^(?:\d+\.|[-*]|\*\*Option|Option [A-C])/i.test(l.trim())
336
- );
174
+ const optionLines = lines.filter((l) => /^(?:\d+\.|[-*]|\*\*Option|Option [A-C])/i.test(l.trim()));
337
175
  if (optionLines.length >= 2) {
338
176
  const summary = optionLines.slice(0, 4).map((l) => l.trim().slice(0, 100)).join("; ");
339
177
  events.push({
@@ -364,7 +202,8 @@ function extractFromDiscussionAssistant(turn, timestamp, sessionId, provider) {
364
202
  }
365
203
  function extractTopic(content) {
366
204
  const firstLine = content.split("\n")[0].trim();
367
- if (firstLine.length < 5 || firstLine.length > 200) return null;
205
+ if (firstLine.length < 5 || firstLine.length > 200)
206
+ return null;
368
207
  const cleaned = firstLine.replace(/^(?:hey|hi|hello|ok|okay|so|well|please|pls|can you|could you)\s+/i, "").trim();
369
208
  return cleaned.length > 5 ? cleaned.slice(0, 100) : null;
370
209
  }
@@ -372,7 +211,8 @@ function deduplicateEvents(events) {
372
211
  const seen = /* @__PURE__ */ new Set();
373
212
  return events.filter((event) => {
374
213
  const key = `${event.type}:${event.summary.toLowerCase().replace(/[^\w\s]/g, "").trim().slice(0, 50)}`;
375
- if (seen.has(key)) return false;
214
+ if (seen.has(key))
215
+ return false;
376
216
  seen.add(key);
377
217
  return true;
378
218
  });
@@ -406,73 +246,245 @@ function generateNarrative(sessionType, events, meta, provider) {
406
246
  const errors = events.filter((e) => e.type === "error");
407
247
  const commits = events.filter((e) => e.type === "commit");
408
248
  const decisions = events.filter((e) => e.type === "decision");
409
- if (decisions.length > 0) parts.push(decisions[0].summary);
249
+ if (decisions.length > 0)
250
+ parts.push(decisions[0].summary);
410
251
  parts.push(`${actions.length} actions`);
411
- if (errors.length > 0) parts.push(`${errors.length} errors`);
412
- if (commits.length > 0) parts.push(`${commits.length} commits`);
252
+ if (errors.length > 0)
253
+ parts.push(`${errors.length} errors`);
254
+ if (commits.length > 0)
255
+ parts.push(`${commits.length} commits`);
413
256
  } else if (strategy === "discussion") {
414
257
  const topics = events.filter((e) => e.type === "topic");
415
258
  const decisions = events.filter((e) => e.type === "decision");
416
- if (topics.length > 0) parts.push(`Discussed: ${topics.map((t) => t.summary).slice(0, 3).join(", ")}`);
417
- if (decisions.length > 0) parts.push(`${decisions.length} decisions`);
259
+ if (topics.length > 0)
260
+ parts.push(`Discussed: ${topics.map((t) => t.summary).slice(0, 3).join(", ")}`);
261
+ if (decisions.length > 0)
262
+ parts.push(`${decisions.length} decisions`);
418
263
  } else if (strategy === "personal") {
419
264
  const facts = events.filter((e) => e.type === "fact" || e.type === "preference");
420
- if (facts.length > 0) parts.push(facts.map((f) => f.summary).join("; "));
265
+ if (facts.length > 0)
266
+ parts.push(facts.map((f) => f.summary).join("; "));
421
267
  } else {
422
268
  parts.push(`${events.length} events`);
423
269
  }
424
270
  return parts.join(" \u2014 ");
425
271
  }
426
272
 
427
- // ../chitragupta/packages/smriti/src/fact-extractor.ts
428
- var DEFAULT_CONFIG = {
429
- minConfidence: 0.5,
430
- useVectors: true,
431
- vectorThreshold: 0.65
273
+ // ../chitragupta/packages/smriti/dist/event-extractor.js
274
+ var DOMAIN_SIGNALS = {
275
+ planning: [
276
+ /\b(?:plan for|roadmap|milestone|timeline|schedule|deadline|sprint|backlog|prioriti[sz]e)\b/i,
277
+ /\b(?:next steps|action items|todo list|to-do list|project plan|gantt|kanban)\b/i,
278
+ /\b(?:due date|estimated time|target date|delivery date|eta for)\b/i
279
+ ],
280
+ learning: [
281
+ /\b(?:teach me|learn about|learn how|tutorial|take a course|study for)\b/i,
282
+ /\b(?:explain to me|help me understand|walkthrough|lesson on)\b/i,
283
+ /\b(?:what is a|what are the|concept of|fundamentals of|theory behind)\b/i
284
+ ],
285
+ creative: [
286
+ /\b(?:write a|draft a|compose a|brainstorm|ideate|creative writing|story about|poem|essay|blog post)\b/i,
287
+ /\b(?:sketch a|mockup|wireframe|logo for|brand identity)\b/i,
288
+ /\b(?:name suggestions|tagline|slogan|elevator pitch)\b/i
289
+ ],
290
+ operational: [
291
+ /\b(?:deploy to|release to|rollback|rollout|uptime|downtime|incident)\b/i,
292
+ /\b(?:docker|kubernetes|k8s|nginx|systemd|terraform|ansible)\b/i,
293
+ /\b(?:infrastructure|ci\/cd pipeline|staging|production environment)\b/i
294
+ ],
295
+ research: [
296
+ /\b(?:research on|investigate|deep dive|literature review|state of the art|sota)\b/i,
297
+ /\b(?:arxiv|paper on|survey of|systematic review|meta-analysis)\b/i,
298
+ /\b(?:pros and cons|tradeoffs? between|trade-offs? between|compare .+ vs)\b/i
299
+ ],
300
+ health: [
301
+ /\b(?:health|wellness|fitness|exercise routine|workout|diet plan|nutrition|calories)\b/i,
302
+ /\b(?:sleep schedule|meditation|mindfulness|mental health|therapy session)\b/i,
303
+ /\b(?:doctor appointment|symptoms of|medicine|prescription|blood pressure)\b/i
304
+ ],
305
+ social: [
306
+ /\b(?:send a message|reply to|draft an email|write an email|schedule a meeting)\b/i,
307
+ /\b(?:birthday|anniversary|gift for|party for|event planning|gathering)\b/i,
308
+ /\b(?:my friend|my family|my colleague|my partner|my wife|my husband)\b/i
309
+ ],
310
+ finance: [
311
+ /\b(?:budget for|monthly expenses|income|salary|payment for|invoice)\b/i,
312
+ /\b(?:invest in|stock|portfolio|crypto|savings account|retirement|tax return)\b/i,
313
+ /\b(?:how much does|subscription|billing|net worth|financial)\b/i
314
+ ],
315
+ reflection: [
316
+ /\b(?:reflect on|journal entry|diary entry|retrospective|look back on)\b/i,
317
+ /\b(?:what went well|what could improve|lessons learned|takeaways from)\b/i,
318
+ /\b(?:grateful for|gratitude|how am i doing|self-assessment)\b/i
319
+ ],
320
+ security: [
321
+ /\b(?:security audit|vulnerability|exploit|threat model|attack vector|data breach)\b/i,
322
+ /\b(?:encrypt|decrypt|ssl certificate|tls|oauth|authentication flow)\b/i,
323
+ /\b(?:access control|firewall rule|security compliance|penetration test|pentest)\b/i
324
+ ]
432
325
  };
433
- var FACT_PATTERNS = [
434
- {
435
- category: "identity",
436
- patterns: [
437
- /(?:my name is|i'm called|call me|i am|i'm)\s+([a-z][a-z\s]{1,30})/i,
438
- /(?:they call me|people call me|everyone calls me)\s+([a-z][a-z\s]{1,30})/i
439
- ],
440
- confidence: 0.9
441
- },
442
- {
443
- category: "location",
444
- patterns: [
445
- /(?:i live in|i'm from|i am from|based in|i'm based in|i reside in|living in|i'm in)\s+([a-z][a-z\s,]{1,50})/i,
446
- /(?:my home is in|my city is|i'm located in|located in)\s+([a-z][a-z\s,]{1,50})/i
447
- ],
448
- confidence: 0.9
449
- },
450
- {
451
- category: "work",
452
- patterns: [
453
- /(?:i work at|i work for|my company is|i'm at|employed at|employed by)\s+([a-z][a-z\s&.]{1,50})/i,
454
- /(?:my job is|my role is|i'm a|i am a|i work as)\s+([a-z][a-z\s]{1,50})/i,
455
- /(?:my team|our team|my department)\s+(?:is|works on)\s+([a-z][a-z\s]{1,50})/i
456
- ],
457
- confidence: 0.85
458
- },
459
- {
460
- category: "preference",
461
- patterns: [
462
- /(?:always use|i prefer|i use|i like using|we use|we always)\s+([a-z][a-z\s./-]{1,50})/i,
463
- /(?:never use|don't use|avoid|i hate|stop using)\s+([a-z][a-z\s./-]{1,50})/i,
464
- /(?:my editor is|my ide is|i code in|i develop in|my stack is)\s+([a-z][a-z\s./-]{1,50})/i
465
- ],
466
- confidence: 0.85
467
- },
468
- {
469
- category: "relationship",
470
- patterns: [
471
- /(?:my wife|my husband|my partner|my girlfriend|my boyfriend)\s+(?:is|'s)\s+([a-z][a-z\s]{1,30})/i,
472
- /(?:my colleague|my friend|my boss|my manager|my coworker)\s+([a-z][a-z\s]{1,30})/i
473
- ],
474
- confidence: 0.85
475
- },
326
+ function scoreDomainSignals(turns) {
327
+ const scores = /* @__PURE__ */ new Map();
328
+ const userContent = turns.filter((t) => t.role === "user").map((t) => t.content).join(" ");
329
+ for (const [domain, patterns] of Object.entries(DOMAIN_SIGNALS)) {
330
+ let groupsMatched = 0;
331
+ for (const pattern of patterns) {
332
+ if (new RegExp(pattern.source, "i").test(userContent)) {
333
+ groupsMatched++;
334
+ }
335
+ }
336
+ if (groupsMatched > 0)
337
+ scores.set(domain, groupsMatched);
338
+ }
339
+ return scores;
340
+ }
341
+ function detectSessionType(turns) {
342
+ if (turns.length === 0)
343
+ return "personal";
344
+ let toolTurns = 0;
345
+ let textTurns = 0;
346
+ let totalUserLength = 0;
347
+ let userTurnCount = 0;
348
+ for (const turn of turns) {
349
+ const hasToolCall = /\[tool:\w+\]/.test(turn.content) || turn.toolCalls && turn.toolCalls.length > 0;
350
+ if (hasToolCall) {
351
+ toolTurns++;
352
+ } else {
353
+ textTurns++;
354
+ }
355
+ if (turn.role === "user") {
356
+ totalUserLength += turn.content.length;
357
+ userTurnCount++;
358
+ }
359
+ }
360
+ const avgUserLength = userTurnCount > 0 ? totalUserLength / userTurnCount : 0;
361
+ const toolRatio = turns.length > 0 ? toolTurns / turns.length : 0;
362
+ let coreType;
363
+ if (turns.length <= 4 && avgUserLength < 100) {
364
+ coreType = "personal";
365
+ } else if (toolRatio > 0.6) {
366
+ coreType = "coding";
367
+ } else if (toolRatio < 0.15) {
368
+ coreType = "discussion";
369
+ } else {
370
+ coreType = "mixed";
371
+ }
372
+ if (coreType === "coding")
373
+ return "coding";
374
+ const domainScores = scoreDomainSignals(turns);
375
+ if (domainScores.size === 0)
376
+ return coreType;
377
+ let topDomain = null;
378
+ let topScore = 0;
379
+ for (const [domain, score] of domainScores) {
380
+ if (score > topScore) {
381
+ topScore = score;
382
+ topDomain = domain;
383
+ }
384
+ }
385
+ if (topDomain && topScore >= 2) {
386
+ return topDomain;
387
+ }
388
+ return coreType;
389
+ }
390
+ function extractEventChain(meta, turns) {
391
+ const sessionType = detectSessionType(turns);
392
+ const provider = meta.provider ?? meta.metadata?.provider ?? meta.agent ?? "unknown";
393
+ const events = [];
394
+ const topics = [];
395
+ const strategy = getExtractorStrategy(sessionType);
396
+ for (let i = 0; i < turns.length; i++) {
397
+ const turn = turns[i];
398
+ const timestamp = turn.createdAt;
399
+ if (turn.role === "user") {
400
+ const userEvents = extractFromUserTurn(turn, timestamp, meta.id, provider);
401
+ events.push(...userEvents);
402
+ const topic = extractTopic(turn.content);
403
+ if (topic && !topics.includes(topic)) {
404
+ topics.push(topic);
405
+ }
406
+ } else if (turn.role === "assistant") {
407
+ switch (strategy) {
408
+ case "coding":
409
+ events.push(...extractFromCodingAssistant(turn, timestamp, meta.id, provider));
410
+ break;
411
+ case "discussion":
412
+ events.push(...extractFromDiscussionAssistant(turn, timestamp, meta.id, provider));
413
+ break;
414
+ case "mixed":
415
+ events.push(...extractFromCodingAssistant(turn, timestamp, meta.id, provider));
416
+ events.push(...extractFromDiscussionAssistant(turn, timestamp, meta.id, provider));
417
+ break;
418
+ case "personal":
419
+ if (turn.content.length < 500) {
420
+ events.push({
421
+ type: "action",
422
+ summary: turn.content.split("\n")[0].slice(0, 200),
423
+ timestamp,
424
+ sessionId: meta.id,
425
+ provider,
426
+ turnNumber: turn.turnNumber
427
+ });
428
+ }
429
+ break;
430
+ }
431
+ }
432
+ }
433
+ const deduped = deduplicateEvents(events);
434
+ deduped.sort((a, b) => a.timestamp - b.timestamp);
435
+ const narrative = generateNarrative(sessionType, deduped, meta, provider);
436
+ return { sessionType, events: deduped, narrative, topics, meta };
437
+ }
438
+
439
+ // ../chitragupta/packages/smriti/dist/fact-extractor.js
440
+ var DEFAULT_CONFIG = {
441
+ minConfidence: 0.5,
442
+ useVectors: true,
443
+ vectorThreshold: 0.65
444
+ };
445
+ var FACT_PATTERNS = [
446
+ {
447
+ category: "identity",
448
+ patterns: [
449
+ /(?:my name is|i'm called|call me|i am|i'm)\s+([a-z][a-z\s]{1,30})/i,
450
+ /(?:they call me|people call me|everyone calls me)\s+([a-z][a-z\s]{1,30})/i
451
+ ],
452
+ confidence: 0.9
453
+ },
454
+ {
455
+ category: "location",
456
+ patterns: [
457
+ /(?:i live in|i'm from|i am from|based in|i'm based in|i reside in|living in|i'm in)\s+([a-z][a-z\s,]{1,50})/i,
458
+ /(?:my home is in|my city is|i'm located in|located in)\s+([a-z][a-z\s,]{1,50})/i
459
+ ],
460
+ confidence: 0.9
461
+ },
462
+ {
463
+ category: "work",
464
+ patterns: [
465
+ /(?:i work at|i work for|my company is|i'm at|employed at|employed by)\s+([a-z][a-z\s&.]{1,50})/i,
466
+ /(?:my job is|my role is|i'm a|i am a|i work as)\s+([a-z][a-z\s]{1,50})/i,
467
+ /(?:my team|our team|my department)\s+(?:is|works on)\s+([a-z][a-z\s]{1,50})/i
468
+ ],
469
+ confidence: 0.85
470
+ },
471
+ {
472
+ category: "preference",
473
+ patterns: [
474
+ /(?:always use|i prefer|i use|i like using|we use|we always)\s+([a-z][a-z\s./-]{1,50})/i,
475
+ /(?:never use|don't use|avoid|i hate|stop using)\s+([a-z][a-z\s./-]{1,50})/i,
476
+ /(?:my editor is|my ide is|i code in|i develop in|my stack is)\s+([a-z][a-z\s./-]{1,50})/i
477
+ ],
478
+ confidence: 0.85
479
+ },
480
+ {
481
+ category: "relationship",
482
+ patterns: [
483
+ /(?:my wife|my husband|my partner|my girlfriend|my boyfriend)\s+(?:is|'s)\s+([a-z][a-z\s]{1,30})/i,
484
+ /(?:my colleague|my friend|my boss|my manager|my coworker)\s+([a-z][a-z\s]{1,30})/i
485
+ ],
486
+ confidence: 0.85
487
+ },
476
488
  {
477
489
  category: "instruction",
478
490
  patterns: [
@@ -523,7 +535,8 @@ var FactExtractor = class {
523
535
  * Initialize vector templates (lazy, on first use).
524
536
  */
525
537
  async ensureInitialized() {
526
- if (this.initialized) return;
538
+ if (this.initialized)
539
+ return;
527
540
  if (!this.config.useVectors) {
528
541
  this.initialized = true;
529
542
  return;
@@ -547,7 +560,8 @@ var FactExtractor = class {
547
560
  async extract(text) {
548
561
  await this.ensureInitialized();
549
562
  const facts = [];
550
- if (text.length < 5 || text.length > 5e3) return facts;
563
+ if (text.length < 5 || text.length > 5e3)
564
+ return facts;
551
565
  for (const rule of FACT_PATTERNS) {
552
566
  for (const pattern of rule.patterns) {
553
567
  const match = text.match(pattern);
@@ -572,7 +586,8 @@ var FactExtractor = class {
572
586
  let bestTemplate = null;
573
587
  for (const tmpl of VECTOR_TEMPLATES) {
574
588
  const tmplEmbedding = this.templateEmbeddings.get(tmpl.template);
575
- if (!tmplEmbedding) continue;
589
+ if (!tmplEmbedding)
590
+ continue;
576
591
  const score = cosineSimilarity(inputEmbedding, tmplEmbedding);
577
592
  if (score > bestScore) {
578
593
  bestScore = score;
@@ -606,14 +621,17 @@ var FactExtractor = class {
606
621
  */
607
622
  async extractAndSave(text, scope, projectScope) {
608
623
  const facts = await this.extract(text);
609
- if (facts.length === 0) return [];
610
- const { appendMemory, getMemory } = await import("./memory-store-A6WOWLWC.js");
624
+ if (facts.length === 0)
625
+ return [];
626
+ const { appendMemory, getMemory } = await import("./memory-store-LEERUQGL.js");
611
627
  const globalScope = scope ?? { type: "global" };
612
628
  const existingMemory = getMemory(globalScope).toLowerCase();
613
629
  for (const fact of facts) {
614
630
  const dedupeKey = `${fact.category}:${fact.fact.toLowerCase().slice(0, 50)}`;
615
- if (this.recentFacts.has(dedupeKey)) continue;
616
- if (existingMemory.includes(fact.fact.toLowerCase().slice(0, 30))) continue;
631
+ if (this.recentFacts.has(dedupeKey))
632
+ continue;
633
+ if (existingMemory.includes(fact.fact.toLowerCase().slice(0, 30)))
634
+ continue;
617
635
  const entry = `[${fact.category}] ${fact.fact}`;
618
636
  if (fact.category === "preference" && projectScope) {
619
637
  await appendMemory(projectScope, entry);
@@ -636,7 +654,8 @@ var FactExtractor = class {
636
654
  };
637
655
  function normalizeFact(category, raw) {
638
656
  const cleaned = raw.replace(/[.!?,;:]+$/, "").trim();
639
- if (cleaned.length < 2) return null;
657
+ if (cleaned.length < 2)
658
+ return null;
640
659
  switch (category) {
641
660
  case "identity":
642
661
  return `Name: ${capitalize(cleaned)}`;
@@ -667,20 +686,221 @@ function getFactExtractor(config) {
667
686
  return _instance;
668
687
  }
669
688
 
670
- // ../chitragupta/packages/smriti/src/day-consolidation.ts
689
+ // ../chitragupta/packages/smriti/dist/day-consolidation-renderer.js
690
+ function generateDayMarkdown(date, projectMap, sessionCount, totalTurns, facts) {
691
+ const lines = [];
692
+ const dayName = (/* @__PURE__ */ new Date(`${date}T12:00:00Z`)).toLocaleDateString("en-US", { weekday: "long" });
693
+ lines.push(`# ${date} \u2014 ${dayName}`);
694
+ lines.push("");
695
+ lines.push(`> ${sessionCount} sessions | ${projectMap.size} projects | ${totalTurns} turns`);
696
+ lines.push("");
697
+ if (facts.length > 0) {
698
+ lines.push("## Facts Learned");
699
+ lines.push("");
700
+ for (const fact of facts) {
701
+ lines.push(`- ${fact}`);
702
+ }
703
+ lines.push("");
704
+ }
705
+ for (const [, activity] of projectMap) {
706
+ renderProjectSection(lines, activity);
707
+ }
708
+ lines.push("---");
709
+ lines.push(`*Consolidated by Chitragupta at ${(/* @__PURE__ */ new Date()).toISOString()}*`);
710
+ lines.push("");
711
+ return lines.join("\n");
712
+ }
713
+ function renderProjectSection(lines, activity) {
714
+ lines.push(`## Project: ${activity.project}`);
715
+ lines.push("");
716
+ const meta = [];
717
+ if (activity.branch)
718
+ meta.push(`**Branch**: ${activity.branch}`);
719
+ meta.push(`**Providers**: ${[...activity.providers].join(", ")}`);
720
+ meta.push(`**Sessions**: ${activity.sessions.length}`);
721
+ if (activity.filesModified.size > 0) {
722
+ meta.push(`**Files Modified**: ${activity.filesModified.size}`);
723
+ }
724
+ lines.push(meta.join(" | "));
725
+ lines.push("");
726
+ for (let i = 0; i < activity.sessions.length; i++) {
727
+ const session = activity.sessions[i];
728
+ const chain = activity.eventChains[i];
729
+ renderSessionSection(lines, session, chain, activity);
730
+ }
731
+ renderToolUsage(lines, activity.eventChains);
732
+ if (activity.filesModified.size > 0) {
733
+ lines.push("### Files Modified");
734
+ lines.push("");
735
+ for (const f of activity.filesModified) {
736
+ lines.push(`- ${f}`);
737
+ }
738
+ lines.push("");
739
+ }
740
+ }
741
+ function renderSessionSection(lines, session, chain, activity) {
742
+ const time = new Date(session.created).toLocaleTimeString("en-US", { hour: "2-digit", minute: "2-digit", hour12: false });
743
+ const provider = session.metadata?.provider ?? session.agent ?? "unknown";
744
+ const turnCount = activity.turns.filter((t) => t.sessionId === session.id).length;
745
+ lines.push(`### Session: ${session.id}`);
746
+ lines.push(`*${time} | ${provider} | ${turnCount} turns | ${chain?.sessionType ?? "unknown"} session*`);
747
+ lines.push("");
748
+ if (chain) {
749
+ if (chain.narrative) {
750
+ lines.push(`> ${chain.narrative}`);
751
+ lines.push("");
752
+ }
753
+ if (chain.topics.length > 0) {
754
+ lines.push(`**Topics**: ${chain.topics.slice(0, 5).join(", ")}`);
755
+ lines.push("");
756
+ }
757
+ const keyEvents = chain.events.filter((e) => e.type === "decision" || e.type === "error" || e.type === "commit" || e.type === "fact" || e.type === "preference");
758
+ if (keyEvents.length > 0) {
759
+ for (const event of keyEvents.slice(0, 10)) {
760
+ const icon = eventIcon(event.type);
761
+ lines.push(`- ${icon} ${event.summary}`);
762
+ }
763
+ lines.push("");
764
+ }
765
+ }
766
+ }
767
+ function renderToolUsage(lines, eventChains) {
768
+ const toolCounts = /* @__PURE__ */ new Map();
769
+ for (const chain of eventChains) {
770
+ for (const event of chain.events) {
771
+ if (event.tool) {
772
+ toolCounts.set(event.tool, (toolCounts.get(event.tool) ?? 0) + 1);
773
+ }
774
+ }
775
+ }
776
+ if (toolCounts.size > 0) {
777
+ lines.push("### Tools Used");
778
+ lines.push("");
779
+ for (const [tool, count] of toolCounts) {
780
+ lines.push(`- **${tool}**: ${count} calls`);
781
+ }
782
+ lines.push("");
783
+ }
784
+ }
785
+ function eventIcon(type) {
786
+ switch (type) {
787
+ case "decision":
788
+ return "**Decision**:";
789
+ case "error":
790
+ return "**Error**:";
791
+ case "commit":
792
+ return "**Commit**:";
793
+ case "fact":
794
+ return "**Fact**:";
795
+ case "preference":
796
+ return "**Pref**:";
797
+ case "question":
798
+ return "**Q**:";
799
+ case "action":
800
+ return "**Action**:";
801
+ case "topic":
802
+ return "**Topic**:";
803
+ case "problem":
804
+ return "**Problem**:";
805
+ default:
806
+ return "-";
807
+ }
808
+ }
809
+
810
+ // ../chitragupta/packages/smriti/dist/day-consolidation-query.js
811
+ import fs from "fs";
812
+ import path from "path";
813
+ function readDayFile(date) {
814
+ const dayPath = getDayFilePath(date);
815
+ if (!fs.existsSync(dayPath))
816
+ return null;
817
+ return fs.readFileSync(dayPath, "utf-8");
818
+ }
819
+ function listDayFiles() {
820
+ const daysRoot = getDaysRoot();
821
+ if (!fs.existsSync(daysRoot))
822
+ return [];
823
+ const dates = [];
824
+ try {
825
+ const years = fs.readdirSync(daysRoot, { withFileTypes: true });
826
+ for (const year of years) {
827
+ if (!year.isDirectory())
828
+ continue;
829
+ const yearPath = path.join(daysRoot, year.name);
830
+ const months = fs.readdirSync(yearPath, { withFileTypes: true });
831
+ for (const month of months) {
832
+ if (!month.isDirectory())
833
+ continue;
834
+ const monthPath = path.join(yearPath, month.name);
835
+ const days = fs.readdirSync(monthPath);
836
+ for (const day of days) {
837
+ if (!day.endsWith(".md"))
838
+ continue;
839
+ const dd = day.replace(".md", "");
840
+ dates.push(`${year.name}-${month.name}-${dd}`);
841
+ }
842
+ }
843
+ }
844
+ } catch {
845
+ }
846
+ return dates.sort().reverse();
847
+ }
848
+ function searchDayFiles(query, options) {
849
+ const limit = options?.limit ?? 10;
850
+ const dates = listDayFiles();
851
+ const results = [];
852
+ const queryLower = query.toLowerCase();
853
+ for (const date of dates) {
854
+ if (results.length >= limit)
855
+ break;
856
+ const content = readDayFile(date);
857
+ if (!content)
858
+ continue;
859
+ const lines = content.split("\n");
860
+ const matches = [];
861
+ for (let i = 0; i < lines.length; i++) {
862
+ if (lines[i].toLowerCase().includes(queryLower)) {
863
+ matches.push({ line: i + 1, text: lines[i].trim() });
864
+ }
865
+ }
866
+ if (matches.length > 0) {
867
+ results.push({ date, matches: matches.slice(0, 5) });
868
+ }
869
+ }
870
+ return results;
871
+ }
872
+ function isDayConsolidated(date) {
873
+ return fs.existsSync(getDayFilePath(date));
874
+ }
875
+ async function getUnconsolidatedDates(limit) {
876
+ const { listSessionDates } = await import("./session-store-O3TS7DUY.js");
877
+ const sessionDates = listSessionDates();
878
+ const unconsolidated = [];
879
+ for (const date of sessionDates) {
880
+ if (unconsolidated.length >= (limit ?? 30))
881
+ break;
882
+ if (!isDayConsolidated(date)) {
883
+ unconsolidated.push(date);
884
+ }
885
+ }
886
+ return unconsolidated;
887
+ }
888
+
889
+ // ../chitragupta/packages/smriti/dist/day-consolidation.js
671
890
  function getDaysRoot() {
672
- return path.join(getChitraguptaHome(), "days");
891
+ return path2.join(getChitraguptaHome(), "days");
673
892
  }
674
893
  function getDayFilePath(date) {
675
894
  const match = date.match(/^(\d{4})-(\d{2})-(\d{2})$/);
676
- if (!match) throw new SessionError(`Invalid date: ${date}. Expected YYYY-MM-DD.`);
677
- return path.join(getDaysRoot(), match[1], match[2], `${match[3]}.md`);
895
+ if (!match)
896
+ throw new SessionError(`Invalid date: ${date}. Expected YYYY-MM-DD.`);
897
+ return path2.join(getDaysRoot(), match[1], match[2], `${match[3]}.md`);
678
898
  }
679
899
  async function consolidateDay(date, options) {
680
900
  const t0 = performance.now();
681
901
  const dayPath = getDayFilePath(date);
682
- if (!options?.force && fs.existsSync(dayPath)) {
683
- const content = fs.readFileSync(dayPath, "utf-8");
902
+ if (!options?.force && fs2.existsSync(dayPath)) {
903
+ const content = fs2.readFileSync(dayPath, "utf-8");
684
904
  const sessionCount = (content.match(/^### Session:/gm) || []).length;
685
905
  return {
686
906
  date,
@@ -696,7 +916,7 @@ async function consolidateDay(date, options) {
696
916
  if (options?.loadSessions) {
697
917
  sessions = await options.loadSessions(date);
698
918
  } else {
699
- const { listSessionsByDate, listTurnsWithTimestamps, loadSession } = await import("./session-store-NDUDYAC7.js");
919
+ const { listSessionsByDate, listTurnsWithTimestamps, loadSession } = await import("./session-store-O3TS7DUY.js");
700
920
  const metas = listSessionsByDate(date);
701
921
  sessions = metas.map((meta) => {
702
922
  try {
@@ -749,7 +969,8 @@ async function consolidateDay(date, options) {
749
969
  activity.sessions.push(meta);
750
970
  const provider = meta.metadata?.provider ?? meta.agent ?? "unknown";
751
971
  activity.providers.add(provider);
752
- if (meta.branch) activity.branch = meta.branch;
972
+ if (meta.branch)
973
+ activity.branch = meta.branch;
753
974
  const eventChain = extractEventChain(meta, turns);
754
975
  activity.eventChains.push(eventChain);
755
976
  for (const turn of turns) {
@@ -767,11 +988,11 @@ async function consolidateDay(date, options) {
767
988
  }
768
989
  const extractedFacts = await extractFactsWithEngine(sessions);
769
990
  const markdown = generateDayMarkdown(date, projectMap, sessions.length, totalTurns, extractedFacts);
770
- const dir = path.dirname(dayPath);
771
- fs.mkdirSync(dir, { recursive: true });
772
- fs.writeFileSync(dayPath, markdown, "utf-8");
991
+ const dir = path2.dirname(dayPath);
992
+ fs2.mkdirSync(dir, { recursive: true });
993
+ fs2.writeFileSync(dayPath, markdown, "utf-8");
773
994
  try {
774
- const { indexConsolidationSummary } = await import("./consolidation-indexer-CD6DS2HO.js");
995
+ const { indexConsolidationSummary } = await import("./consolidation-indexer-VIWOP6VO.js");
775
996
  await indexConsolidationSummary("daily", date, markdown);
776
997
  } catch {
777
998
  }
@@ -792,8 +1013,10 @@ async function extractFactsWithEngine(sessions) {
792
1013
  const extractor = new FactExtractor({ useVectors: true });
793
1014
  for (const { turns } of sessions) {
794
1015
  for (const turn of turns) {
795
- if (turn.role !== "user") continue;
796
- if (turn.content.length < 5 || turn.content.length > 5e3) continue;
1016
+ if (turn.role !== "user")
1017
+ continue;
1018
+ if (turn.content.length < 5 || turn.content.length > 5e3)
1019
+ continue;
797
1020
  const extracted = await extractor.extract(turn.content);
798
1021
  for (const fact of extracted) {
799
1022
  const key = fact.fact.toLowerCase().slice(0, 50);
@@ -821,7 +1044,8 @@ function extractFactsFallback(sessions) {
821
1044
  ];
822
1045
  for (const { turns } of sessions) {
823
1046
  for (const turn of turns) {
824
- if (turn.role !== "user") continue;
1047
+ if (turn.role !== "user")
1048
+ continue;
825
1049
  for (const pattern of factPatterns) {
826
1050
  const match = turn.content.match(pattern);
827
1051
  if (match) {
@@ -832,198 +1056,22 @@ function extractFactsFallback(sessions) {
832
1056
  }
833
1057
  return [...new Set(facts)];
834
1058
  }
835
- function generateDayMarkdown(date, projectMap, sessionCount, totalTurns, facts) {
836
- const lines = [];
837
- const dayName = (/* @__PURE__ */ new Date(`${date}T12:00:00Z`)).toLocaleDateString("en-US", { weekday: "long" });
838
- lines.push(`# ${date} \u2014 ${dayName}`);
839
- lines.push("");
840
- lines.push(`> ${sessionCount} sessions | ${projectMap.size} projects | ${totalTurns} turns`);
841
- lines.push("");
842
- if (facts.length > 0) {
843
- lines.push("## Facts Learned");
844
- lines.push("");
845
- for (const fact of facts) {
846
- lines.push(`- ${fact}`);
847
- }
848
- lines.push("");
849
- }
850
- for (const [, activity] of projectMap) {
851
- lines.push(`## Project: ${activity.project}`);
852
- lines.push("");
853
- const meta = [];
854
- if (activity.branch) meta.push(`**Branch**: ${activity.branch}`);
855
- meta.push(`**Providers**: ${[...activity.providers].join(", ")}`);
856
- meta.push(`**Sessions**: ${activity.sessions.length}`);
857
- if (activity.filesModified.size > 0) {
858
- meta.push(`**Files Modified**: ${activity.filesModified.size}`);
859
- }
860
- lines.push(meta.join(" | "));
861
- lines.push("");
862
- for (let i = 0; i < activity.sessions.length; i++) {
863
- const session = activity.sessions[i];
864
- const chain = activity.eventChains[i];
865
- const time = new Date(session.created).toLocaleTimeString("en-US", { hour: "2-digit", minute: "2-digit", hour12: false });
866
- const provider = session.metadata?.provider ?? session.agent ?? "unknown";
867
- const turnCount = activity.turns.filter((t) => t.sessionId === session.id).length;
868
- lines.push(`### Session: ${session.id}`);
869
- lines.push(`*${time} | ${provider} | ${turnCount} turns | ${chain?.sessionType ?? "unknown"} session*`);
870
- lines.push("");
871
- if (chain) {
872
- if (chain.narrative) {
873
- lines.push(`> ${chain.narrative}`);
874
- lines.push("");
875
- }
876
- if (chain.topics.length > 0) {
877
- lines.push(`**Topics**: ${chain.topics.slice(0, 5).join(", ")}`);
878
- lines.push("");
879
- }
880
- const keyEvents = chain.events.filter(
881
- (e) => e.type === "decision" || e.type === "error" || e.type === "commit" || e.type === "fact" || e.type === "preference"
882
- );
883
- if (keyEvents.length > 0) {
884
- for (const event of keyEvents.slice(0, 10)) {
885
- const icon = eventIcon(event.type);
886
- lines.push(`- ${icon} ${event.summary}`);
887
- }
888
- lines.push("");
889
- }
890
- }
891
- }
892
- const toolCounts = /* @__PURE__ */ new Map();
893
- for (const chain of activity.eventChains) {
894
- for (const event of chain.events) {
895
- if (event.tool) {
896
- toolCounts.set(event.tool, (toolCounts.get(event.tool) ?? 0) + 1);
897
- }
898
- }
899
- }
900
- if (toolCounts.size > 0) {
901
- lines.push("### Tools Used");
902
- lines.push("");
903
- for (const [tool, count] of toolCounts) {
904
- lines.push(`- **${tool}**: ${count} calls`);
905
- }
906
- lines.push("");
907
- }
908
- if (activity.filesModified.size > 0) {
909
- lines.push("### Files Modified");
910
- lines.push("");
911
- for (const f of activity.filesModified) {
912
- lines.push(`- ${f}`);
913
- }
914
- lines.push("");
915
- }
916
- }
917
- lines.push("---");
918
- lines.push(`*Consolidated by Chitragupta at ${(/* @__PURE__ */ new Date()).toISOString()}*`);
919
- lines.push("");
920
- return lines.join("\n");
921
- }
922
- function eventIcon(type) {
923
- switch (type) {
924
- case "decision":
925
- return "**Decision**:";
926
- case "error":
927
- return "**Error**:";
928
- case "commit":
929
- return "**Commit**:";
930
- case "fact":
931
- return "**Fact**:";
932
- case "preference":
933
- return "**Pref**:";
934
- case "question":
935
- return "**Q**:";
936
- case "action":
937
- return "**Action**:";
938
- case "topic":
939
- return "**Topic**:";
940
- case "problem":
941
- return "**Problem**:";
942
- default:
943
- return "-";
944
- }
945
- }
946
- function readDayFile(date) {
947
- const dayPath = getDayFilePath(date);
948
- if (!fs.existsSync(dayPath)) return null;
949
- return fs.readFileSync(dayPath, "utf-8");
950
- }
951
- function listDayFiles() {
952
- const daysRoot = getDaysRoot();
953
- if (!fs.existsSync(daysRoot)) return [];
954
- const dates = [];
955
- try {
956
- const years = fs.readdirSync(daysRoot, { withFileTypes: true });
957
- for (const year of years) {
958
- if (!year.isDirectory()) continue;
959
- const yearPath = path.join(daysRoot, year.name);
960
- const months = fs.readdirSync(yearPath, { withFileTypes: true });
961
- for (const month of months) {
962
- if (!month.isDirectory()) continue;
963
- const monthPath = path.join(yearPath, month.name);
964
- const days = fs.readdirSync(monthPath);
965
- for (const day of days) {
966
- if (!day.endsWith(".md")) continue;
967
- const dd = day.replace(".md", "");
968
- dates.push(`${year.name}-${month.name}-${dd}`);
969
- }
970
- }
971
- }
972
- } catch {
973
- }
974
- return dates.sort().reverse();
975
- }
976
- function searchDayFiles(query, options) {
977
- const limit = options?.limit ?? 10;
978
- const dates = listDayFiles();
979
- const results = [];
980
- const queryLower = query.toLowerCase();
981
- for (const date of dates) {
982
- if (results.length >= limit) break;
983
- const content = readDayFile(date);
984
- if (!content) continue;
985
- const lines = content.split("\n");
986
- const matches = [];
987
- for (let i = 0; i < lines.length; i++) {
988
- if (lines[i].toLowerCase().includes(queryLower)) {
989
- matches.push({ line: i + 1, text: lines[i].trim() });
990
- }
991
- }
992
- if (matches.length > 0) {
993
- results.push({ date, matches: matches.slice(0, 5) });
994
- }
995
- }
996
- return results;
997
- }
998
- function isDayConsolidated(date) {
999
- return fs.existsSync(getDayFilePath(date));
1000
- }
1001
- async function getUnconsolidatedDates(limit) {
1002
- const { listSessionDates } = await import("./session-store-NDUDYAC7.js");
1003
- const sessionDates = listSessionDates();
1004
- const unconsolidated = [];
1005
- for (const date of sessionDates) {
1006
- if (unconsolidated.length >= (limit ?? 30)) break;
1007
- if (!isDayConsolidated(date)) {
1008
- unconsolidated.push(date);
1009
- }
1010
- }
1011
- return unconsolidated;
1012
- }
1013
1059
 
1014
1060
  export {
1015
- detectSessionType,
1016
1061
  getExtractorStrategy,
1062
+ detectSessionType,
1017
1063
  extractEventChain,
1018
1064
  FactExtractor,
1019
1065
  getFactExtractor,
1020
- getDaysRoot,
1021
- getDayFilePath,
1022
- consolidateDay,
1066
+ generateDayMarkdown,
1067
+ eventIcon,
1023
1068
  readDayFile,
1024
1069
  listDayFiles,
1025
1070
  searchDayFiles,
1026
1071
  isDayConsolidated,
1027
- getUnconsolidatedDates
1072
+ getUnconsolidatedDates,
1073
+ getDaysRoot,
1074
+ getDayFilePath,
1075
+ consolidateDay
1028
1076
  };
1029
- //# sourceMappingURL=chunk-7UOXFHEB.js.map
1077
+ //# sourceMappingURL=chunk-F6RNEGFX.js.map