@yugenlab/vaayu 0.1.9 → 0.1.10
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/chunks/{chunk-7UOXFHEB.js → chunk-77725AR7.js} +416 -397
- package/chunks/{chunk-YSC77CKZ.js → chunk-AGK3A7R7.js} +2844 -3208
- package/chunks/{chunk-DOQMEQ5S.js → chunk-AS3DJFY3.js} +5 -5
- package/chunks/{chunk-NHRBVSN3.js → chunk-HIYHTWFW.js} +44 -9
- package/chunks/{chunk-IGBRBFXX.js → chunk-JGI4SDWS.js} +2 -2
- package/chunks/{chunk-D3RVJGO7.js → chunk-M7THR63C.js} +48 -74
- package/chunks/{chunk-OBYBBGHA.js → chunk-N22M7D4P.js} +118 -106
- package/chunks/{chunk-PJEYJQ2C.js → chunk-O4KV7TFP.js} +2 -2
- package/chunks/{chunk-S2HDNNC7.js → chunk-OT4G2L46.js} +552 -641
- package/chunks/chunk-TND3MU4Z.js +426 -0
- package/chunks/{chunk-LVE2EOOH.js → chunk-VJHNE47S.js} +84 -75
- package/chunks/{consolidation-indexer-CD6DS2HO.js → consolidation-indexer-VKQ6DNU3.js} +4 -4
- package/chunks/{day-consolidation-U3X6P4ZG.js → day-consolidation-BH3QU2SZ.js} +6 -2
- package/chunks/{graphrag-LAZSXLLI.js → graphrag-D7OXWAWD.js} +2 -2
- package/chunks/{hierarchical-temporal-search-ETXYYJZK.js → hierarchical-temporal-search-PVHVA3NZ.js} +2 -2
- package/chunks/{hybrid-search-TX6T3KYH.js → hybrid-search-G2NAJKJ7.js} +4 -4
- package/chunks/{periodic-consolidation-4MACZE6S.js → periodic-consolidation-LMYMNS4Q.js} +2 -2
- package/chunks/{recall-IUPQCBYP.js → recall-ZNL4DJ2L.js} +3 -3
- package/chunks/{search-HHSVHBXC.js → search-35JMSGUT.js} +3 -3
- package/chunks/{session-store-NDUDYAC7.js → session-store-3BRPGC6P.js} +2 -2
- package/chunks/{src-ZAKUL232.js → src-Y3TGMINC.js} +12 -12
- package/chunks/vasana-engine-MU25OQ23.js +30 -0
- package/gateway.js +492 -226
- package/package.json +1 -1
- package/chunks/chunk-TEQKXGIK.js +0 -752
- package/chunks/vasana-engine-G6BPOFX7.js +0 -10
|
@@ -9,62 +9,10 @@ import {
|
|
|
9
9
|
} from "./chunk-UZ6OIVEC.js";
|
|
10
10
|
|
|
11
11
|
// ../chitragupta/packages/smriti/src/day-consolidation.ts
|
|
12
|
-
import
|
|
13
|
-
import
|
|
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/src/event-extractor-strategies.ts
|
|
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();
|
|
@@ -424,48 +264,210 @@ function generateNarrative(sessionType, events, meta, provider) {
|
|
|
424
264
|
return parts.join(" \u2014 ");
|
|
425
265
|
}
|
|
426
266
|
|
|
427
|
-
// ../chitragupta/packages/smriti/src/
|
|
428
|
-
var
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
267
|
+
// ../chitragupta/packages/smriti/src/event-extractor.ts
|
|
268
|
+
var DOMAIN_SIGNALS = {
|
|
269
|
+
planning: [
|
|
270
|
+
/\b(?:plan for|roadmap|milestone|timeline|schedule|deadline|sprint|backlog|prioriti[sz]e)\b/i,
|
|
271
|
+
/\b(?:next steps|action items|todo list|to-do list|project plan|gantt|kanban)\b/i,
|
|
272
|
+
/\b(?:due date|estimated time|target date|delivery date|eta for)\b/i
|
|
273
|
+
],
|
|
274
|
+
learning: [
|
|
275
|
+
/\b(?:teach me|learn about|learn how|tutorial|take a course|study for)\b/i,
|
|
276
|
+
/\b(?:explain to me|help me understand|walkthrough|lesson on)\b/i,
|
|
277
|
+
/\b(?:what is a|what are the|concept of|fundamentals of|theory behind)\b/i
|
|
278
|
+
],
|
|
279
|
+
creative: [
|
|
280
|
+
/\b(?:write a|draft a|compose a|brainstorm|ideate|creative writing|story about|poem|essay|blog post)\b/i,
|
|
281
|
+
/\b(?:sketch a|mockup|wireframe|logo for|brand identity)\b/i,
|
|
282
|
+
/\b(?:name suggestions|tagline|slogan|elevator pitch)\b/i
|
|
283
|
+
],
|
|
284
|
+
operational: [
|
|
285
|
+
/\b(?:deploy to|release to|rollback|rollout|uptime|downtime|incident)\b/i,
|
|
286
|
+
/\b(?:docker|kubernetes|k8s|nginx|systemd|terraform|ansible)\b/i,
|
|
287
|
+
/\b(?:infrastructure|ci\/cd pipeline|staging|production environment)\b/i
|
|
288
|
+
],
|
|
289
|
+
research: [
|
|
290
|
+
/\b(?:research on|investigate|deep dive|literature review|state of the art|sota)\b/i,
|
|
291
|
+
/\b(?:arxiv|paper on|survey of|systematic review|meta-analysis)\b/i,
|
|
292
|
+
/\b(?:pros and cons|tradeoffs? between|trade-offs? between|compare .+ vs)\b/i
|
|
293
|
+
],
|
|
294
|
+
health: [
|
|
295
|
+
/\b(?:health|wellness|fitness|exercise routine|workout|diet plan|nutrition|calories)\b/i,
|
|
296
|
+
/\b(?:sleep schedule|meditation|mindfulness|mental health|therapy session)\b/i,
|
|
297
|
+
/\b(?:doctor appointment|symptoms of|medicine|prescription|blood pressure)\b/i
|
|
298
|
+
],
|
|
299
|
+
social: [
|
|
300
|
+
/\b(?:send a message|reply to|draft an email|write an email|schedule a meeting)\b/i,
|
|
301
|
+
/\b(?:birthday|anniversary|gift for|party for|event planning|gathering)\b/i,
|
|
302
|
+
/\b(?:my friend|my family|my colleague|my partner|my wife|my husband)\b/i
|
|
303
|
+
],
|
|
304
|
+
finance: [
|
|
305
|
+
/\b(?:budget for|monthly expenses|income|salary|payment for|invoice)\b/i,
|
|
306
|
+
/\b(?:invest in|stock|portfolio|crypto|savings account|retirement|tax return)\b/i,
|
|
307
|
+
/\b(?:how much does|subscription|billing|net worth|financial)\b/i
|
|
308
|
+
],
|
|
309
|
+
reflection: [
|
|
310
|
+
/\b(?:reflect on|journal entry|diary entry|retrospective|look back on)\b/i,
|
|
311
|
+
/\b(?:what went well|what could improve|lessons learned|takeaways from)\b/i,
|
|
312
|
+
/\b(?:grateful for|gratitude|how am i doing|self-assessment)\b/i
|
|
313
|
+
],
|
|
314
|
+
security: [
|
|
315
|
+
/\b(?:security audit|vulnerability|exploit|threat model|attack vector|data breach)\b/i,
|
|
316
|
+
/\b(?:encrypt|decrypt|ssl certificate|tls|oauth|authentication flow)\b/i,
|
|
317
|
+
/\b(?:access control|firewall rule|security compliance|penetration test|pentest)\b/i
|
|
318
|
+
]
|
|
432
319
|
};
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
{
|
|
320
|
+
function scoreDomainSignals(turns) {
|
|
321
|
+
const scores = /* @__PURE__ */ new Map();
|
|
322
|
+
const userContent = turns.filter((t) => t.role === "user").map((t) => t.content).join(" ");
|
|
323
|
+
for (const [domain, patterns] of Object.entries(DOMAIN_SIGNALS)) {
|
|
324
|
+
let groupsMatched = 0;
|
|
325
|
+
for (const pattern of patterns) {
|
|
326
|
+
if (new RegExp(pattern.source, "i").test(userContent)) {
|
|
327
|
+
groupsMatched++;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (groupsMatched > 0) scores.set(domain, groupsMatched);
|
|
331
|
+
}
|
|
332
|
+
return scores;
|
|
333
|
+
}
|
|
334
|
+
function detectSessionType(turns) {
|
|
335
|
+
if (turns.length === 0) return "personal";
|
|
336
|
+
let toolTurns = 0;
|
|
337
|
+
let textTurns = 0;
|
|
338
|
+
let totalUserLength = 0;
|
|
339
|
+
let userTurnCount = 0;
|
|
340
|
+
for (const turn of turns) {
|
|
341
|
+
const hasToolCall = /\[tool:\w+\]/.test(turn.content) || turn.toolCalls && turn.toolCalls.length > 0;
|
|
342
|
+
if (hasToolCall) {
|
|
343
|
+
toolTurns++;
|
|
344
|
+
} else {
|
|
345
|
+
textTurns++;
|
|
346
|
+
}
|
|
347
|
+
if (turn.role === "user") {
|
|
348
|
+
totalUserLength += turn.content.length;
|
|
349
|
+
userTurnCount++;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
const avgUserLength = userTurnCount > 0 ? totalUserLength / userTurnCount : 0;
|
|
353
|
+
const toolRatio = turns.length > 0 ? toolTurns / turns.length : 0;
|
|
354
|
+
let coreType;
|
|
355
|
+
if (turns.length <= 4 && avgUserLength < 100) {
|
|
356
|
+
coreType = "personal";
|
|
357
|
+
} else if (toolRatio > 0.6) {
|
|
358
|
+
coreType = "coding";
|
|
359
|
+
} else if (toolRatio < 0.15) {
|
|
360
|
+
coreType = "discussion";
|
|
361
|
+
} else {
|
|
362
|
+
coreType = "mixed";
|
|
363
|
+
}
|
|
364
|
+
if (coreType === "coding") return "coding";
|
|
365
|
+
const domainScores = scoreDomainSignals(turns);
|
|
366
|
+
if (domainScores.size === 0) return coreType;
|
|
367
|
+
let topDomain = null;
|
|
368
|
+
let topScore = 0;
|
|
369
|
+
for (const [domain, score] of domainScores) {
|
|
370
|
+
if (score > topScore) {
|
|
371
|
+
topScore = score;
|
|
372
|
+
topDomain = domain;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
if (topDomain && topScore >= 2) {
|
|
376
|
+
return topDomain;
|
|
377
|
+
}
|
|
378
|
+
return coreType;
|
|
379
|
+
}
|
|
380
|
+
function extractEventChain(meta, turns) {
|
|
381
|
+
const sessionType = detectSessionType(turns);
|
|
382
|
+
const provider = meta.provider ?? meta.metadata?.provider ?? meta.agent ?? "unknown";
|
|
383
|
+
const events = [];
|
|
384
|
+
const topics = [];
|
|
385
|
+
const strategy = getExtractorStrategy(sessionType);
|
|
386
|
+
for (let i = 0; i < turns.length; i++) {
|
|
387
|
+
const turn = turns[i];
|
|
388
|
+
const timestamp = turn.createdAt;
|
|
389
|
+
if (turn.role === "user") {
|
|
390
|
+
const userEvents = extractFromUserTurn(turn, timestamp, meta.id, provider);
|
|
391
|
+
events.push(...userEvents);
|
|
392
|
+
const topic = extractTopic(turn.content);
|
|
393
|
+
if (topic && !topics.includes(topic)) {
|
|
394
|
+
topics.push(topic);
|
|
395
|
+
}
|
|
396
|
+
} else if (turn.role === "assistant") {
|
|
397
|
+
switch (strategy) {
|
|
398
|
+
case "coding":
|
|
399
|
+
events.push(...extractFromCodingAssistant(turn, timestamp, meta.id, provider));
|
|
400
|
+
break;
|
|
401
|
+
case "discussion":
|
|
402
|
+
events.push(...extractFromDiscussionAssistant(turn, timestamp, meta.id, provider));
|
|
403
|
+
break;
|
|
404
|
+
case "mixed":
|
|
405
|
+
events.push(...extractFromCodingAssistant(turn, timestamp, meta.id, provider));
|
|
406
|
+
events.push(...extractFromDiscussionAssistant(turn, timestamp, meta.id, provider));
|
|
407
|
+
break;
|
|
408
|
+
case "personal":
|
|
409
|
+
if (turn.content.length < 500) {
|
|
410
|
+
events.push({
|
|
411
|
+
type: "action",
|
|
412
|
+
summary: turn.content.split("\n")[0].slice(0, 200),
|
|
413
|
+
timestamp,
|
|
414
|
+
sessionId: meta.id,
|
|
415
|
+
provider,
|
|
416
|
+
turnNumber: turn.turnNumber
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
const deduped = deduplicateEvents(events);
|
|
424
|
+
deduped.sort((a, b) => a.timestamp - b.timestamp);
|
|
425
|
+
const narrative = generateNarrative(sessionType, deduped, meta, provider);
|
|
426
|
+
return { sessionType, events: deduped, narrative, topics, meta };
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// ../chitragupta/packages/smriti/src/fact-extractor.ts
|
|
430
|
+
var DEFAULT_CONFIG = {
|
|
431
|
+
minConfidence: 0.5,
|
|
432
|
+
useVectors: true,
|
|
433
|
+
vectorThreshold: 0.65
|
|
434
|
+
};
|
|
435
|
+
var FACT_PATTERNS = [
|
|
436
|
+
{
|
|
437
|
+
category: "identity",
|
|
438
|
+
patterns: [
|
|
439
|
+
/(?:my name is|i'm called|call me|i am|i'm)\s+([a-z][a-z\s]{1,30})/i,
|
|
440
|
+
/(?:they call me|people call me|everyone calls me)\s+([a-z][a-z\s]{1,30})/i
|
|
441
|
+
],
|
|
442
|
+
confidence: 0.9
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
category: "location",
|
|
446
|
+
patterns: [
|
|
447
|
+
/(?: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,
|
|
448
|
+
/(?:my home is in|my city is|i'm located in|located in)\s+([a-z][a-z\s,]{1,50})/i
|
|
449
|
+
],
|
|
450
|
+
confidence: 0.9
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
category: "work",
|
|
454
|
+
patterns: [
|
|
455
|
+
/(?: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,
|
|
456
|
+
/(?:my job is|my role is|i'm a|i am a|i work as)\s+([a-z][a-z\s]{1,50})/i,
|
|
457
|
+
/(?:my team|our team|my department)\s+(?:is|works on)\s+([a-z][a-z\s]{1,50})/i
|
|
458
|
+
],
|
|
459
|
+
confidence: 0.85
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
category: "preference",
|
|
463
|
+
patterns: [
|
|
464
|
+
/(?:always use|i prefer|i use|i like using|we use|we always)\s+([a-z][a-z\s./-]{1,50})/i,
|
|
465
|
+
/(?:never use|don't use|avoid|i hate|stop using)\s+([a-z][a-z\s./-]{1,50})/i,
|
|
466
|
+
/(?:my editor is|my ide is|i code in|i develop in|my stack is)\s+([a-z][a-z\s./-]{1,50})/i
|
|
467
|
+
],
|
|
468
|
+
confidence: 0.85
|
|
469
|
+
},
|
|
470
|
+
{
|
|
469
471
|
category: "relationship",
|
|
470
472
|
patterns: [
|
|
471
473
|
/(?:my wife|my husband|my partner|my girlfriend|my boyfriend)\s+(?:is|'s)\s+([a-z][a-z\s]{1,30})/i,
|
|
@@ -667,20 +669,213 @@ function getFactExtractor(config) {
|
|
|
667
669
|
return _instance;
|
|
668
670
|
}
|
|
669
671
|
|
|
672
|
+
// ../chitragupta/packages/smriti/src/day-consolidation-renderer.ts
|
|
673
|
+
function generateDayMarkdown(date, projectMap, sessionCount, totalTurns, facts) {
|
|
674
|
+
const lines = [];
|
|
675
|
+
const dayName = (/* @__PURE__ */ new Date(`${date}T12:00:00Z`)).toLocaleDateString("en-US", { weekday: "long" });
|
|
676
|
+
lines.push(`# ${date} \u2014 ${dayName}`);
|
|
677
|
+
lines.push("");
|
|
678
|
+
lines.push(`> ${sessionCount} sessions | ${projectMap.size} projects | ${totalTurns} turns`);
|
|
679
|
+
lines.push("");
|
|
680
|
+
if (facts.length > 0) {
|
|
681
|
+
lines.push("## Facts Learned");
|
|
682
|
+
lines.push("");
|
|
683
|
+
for (const fact of facts) {
|
|
684
|
+
lines.push(`- ${fact}`);
|
|
685
|
+
}
|
|
686
|
+
lines.push("");
|
|
687
|
+
}
|
|
688
|
+
for (const [, activity] of projectMap) {
|
|
689
|
+
renderProjectSection(lines, activity);
|
|
690
|
+
}
|
|
691
|
+
lines.push("---");
|
|
692
|
+
lines.push(`*Consolidated by Chitragupta at ${(/* @__PURE__ */ new Date()).toISOString()}*`);
|
|
693
|
+
lines.push("");
|
|
694
|
+
return lines.join("\n");
|
|
695
|
+
}
|
|
696
|
+
function renderProjectSection(lines, activity) {
|
|
697
|
+
lines.push(`## Project: ${activity.project}`);
|
|
698
|
+
lines.push("");
|
|
699
|
+
const meta = [];
|
|
700
|
+
if (activity.branch) meta.push(`**Branch**: ${activity.branch}`);
|
|
701
|
+
meta.push(`**Providers**: ${[...activity.providers].join(", ")}`);
|
|
702
|
+
meta.push(`**Sessions**: ${activity.sessions.length}`);
|
|
703
|
+
if (activity.filesModified.size > 0) {
|
|
704
|
+
meta.push(`**Files Modified**: ${activity.filesModified.size}`);
|
|
705
|
+
}
|
|
706
|
+
lines.push(meta.join(" | "));
|
|
707
|
+
lines.push("");
|
|
708
|
+
for (let i = 0; i < activity.sessions.length; i++) {
|
|
709
|
+
const session = activity.sessions[i];
|
|
710
|
+
const chain = activity.eventChains[i];
|
|
711
|
+
renderSessionSection(lines, session, chain, activity);
|
|
712
|
+
}
|
|
713
|
+
renderToolUsage(lines, activity.eventChains);
|
|
714
|
+
if (activity.filesModified.size > 0) {
|
|
715
|
+
lines.push("### Files Modified");
|
|
716
|
+
lines.push("");
|
|
717
|
+
for (const f of activity.filesModified) {
|
|
718
|
+
lines.push(`- ${f}`);
|
|
719
|
+
}
|
|
720
|
+
lines.push("");
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
function renderSessionSection(lines, session, chain, activity) {
|
|
724
|
+
const time = new Date(session.created).toLocaleTimeString("en-US", { hour: "2-digit", minute: "2-digit", hour12: false });
|
|
725
|
+
const provider = session.metadata?.provider ?? session.agent ?? "unknown";
|
|
726
|
+
const turnCount = activity.turns.filter((t) => t.sessionId === session.id).length;
|
|
727
|
+
lines.push(`### Session: ${session.id}`);
|
|
728
|
+
lines.push(`*${time} | ${provider} | ${turnCount} turns | ${chain?.sessionType ?? "unknown"} session*`);
|
|
729
|
+
lines.push("");
|
|
730
|
+
if (chain) {
|
|
731
|
+
if (chain.narrative) {
|
|
732
|
+
lines.push(`> ${chain.narrative}`);
|
|
733
|
+
lines.push("");
|
|
734
|
+
}
|
|
735
|
+
if (chain.topics.length > 0) {
|
|
736
|
+
lines.push(`**Topics**: ${chain.topics.slice(0, 5).join(", ")}`);
|
|
737
|
+
lines.push("");
|
|
738
|
+
}
|
|
739
|
+
const keyEvents = chain.events.filter(
|
|
740
|
+
(e) => e.type === "decision" || e.type === "error" || e.type === "commit" || e.type === "fact" || e.type === "preference"
|
|
741
|
+
);
|
|
742
|
+
if (keyEvents.length > 0) {
|
|
743
|
+
for (const event of keyEvents.slice(0, 10)) {
|
|
744
|
+
const icon = eventIcon(event.type);
|
|
745
|
+
lines.push(`- ${icon} ${event.summary}`);
|
|
746
|
+
}
|
|
747
|
+
lines.push("");
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
function renderToolUsage(lines, eventChains) {
|
|
752
|
+
const toolCounts = /* @__PURE__ */ new Map();
|
|
753
|
+
for (const chain of eventChains) {
|
|
754
|
+
for (const event of chain.events) {
|
|
755
|
+
if (event.tool) {
|
|
756
|
+
toolCounts.set(event.tool, (toolCounts.get(event.tool) ?? 0) + 1);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
if (toolCounts.size > 0) {
|
|
761
|
+
lines.push("### Tools Used");
|
|
762
|
+
lines.push("");
|
|
763
|
+
for (const [tool, count] of toolCounts) {
|
|
764
|
+
lines.push(`- **${tool}**: ${count} calls`);
|
|
765
|
+
}
|
|
766
|
+
lines.push("");
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
function eventIcon(type) {
|
|
770
|
+
switch (type) {
|
|
771
|
+
case "decision":
|
|
772
|
+
return "**Decision**:";
|
|
773
|
+
case "error":
|
|
774
|
+
return "**Error**:";
|
|
775
|
+
case "commit":
|
|
776
|
+
return "**Commit**:";
|
|
777
|
+
case "fact":
|
|
778
|
+
return "**Fact**:";
|
|
779
|
+
case "preference":
|
|
780
|
+
return "**Pref**:";
|
|
781
|
+
case "question":
|
|
782
|
+
return "**Q**:";
|
|
783
|
+
case "action":
|
|
784
|
+
return "**Action**:";
|
|
785
|
+
case "topic":
|
|
786
|
+
return "**Topic**:";
|
|
787
|
+
case "problem":
|
|
788
|
+
return "**Problem**:";
|
|
789
|
+
default:
|
|
790
|
+
return "-";
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
// ../chitragupta/packages/smriti/src/day-consolidation-query.ts
|
|
795
|
+
import fs from "fs";
|
|
796
|
+
import path from "path";
|
|
797
|
+
function readDayFile(date) {
|
|
798
|
+
const dayPath = getDayFilePath(date);
|
|
799
|
+
if (!fs.existsSync(dayPath)) return null;
|
|
800
|
+
return fs.readFileSync(dayPath, "utf-8");
|
|
801
|
+
}
|
|
802
|
+
function listDayFiles() {
|
|
803
|
+
const daysRoot = getDaysRoot();
|
|
804
|
+
if (!fs.existsSync(daysRoot)) return [];
|
|
805
|
+
const dates = [];
|
|
806
|
+
try {
|
|
807
|
+
const years = fs.readdirSync(daysRoot, { withFileTypes: true });
|
|
808
|
+
for (const year of years) {
|
|
809
|
+
if (!year.isDirectory()) continue;
|
|
810
|
+
const yearPath = path.join(daysRoot, year.name);
|
|
811
|
+
const months = fs.readdirSync(yearPath, { withFileTypes: true });
|
|
812
|
+
for (const month of months) {
|
|
813
|
+
if (!month.isDirectory()) continue;
|
|
814
|
+
const monthPath = path.join(yearPath, month.name);
|
|
815
|
+
const days = fs.readdirSync(monthPath);
|
|
816
|
+
for (const day of days) {
|
|
817
|
+
if (!day.endsWith(".md")) continue;
|
|
818
|
+
const dd = day.replace(".md", "");
|
|
819
|
+
dates.push(`${year.name}-${month.name}-${dd}`);
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
} catch {
|
|
824
|
+
}
|
|
825
|
+
return dates.sort().reverse();
|
|
826
|
+
}
|
|
827
|
+
function searchDayFiles(query, options) {
|
|
828
|
+
const limit = options?.limit ?? 10;
|
|
829
|
+
const dates = listDayFiles();
|
|
830
|
+
const results = [];
|
|
831
|
+
const queryLower = query.toLowerCase();
|
|
832
|
+
for (const date of dates) {
|
|
833
|
+
if (results.length >= limit) break;
|
|
834
|
+
const content = readDayFile(date);
|
|
835
|
+
if (!content) continue;
|
|
836
|
+
const lines = content.split("\n");
|
|
837
|
+
const matches = [];
|
|
838
|
+
for (let i = 0; i < lines.length; i++) {
|
|
839
|
+
if (lines[i].toLowerCase().includes(queryLower)) {
|
|
840
|
+
matches.push({ line: i + 1, text: lines[i].trim() });
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
if (matches.length > 0) {
|
|
844
|
+
results.push({ date, matches: matches.slice(0, 5) });
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
return results;
|
|
848
|
+
}
|
|
849
|
+
function isDayConsolidated(date) {
|
|
850
|
+
return fs.existsSync(getDayFilePath(date));
|
|
851
|
+
}
|
|
852
|
+
async function getUnconsolidatedDates(limit) {
|
|
853
|
+
const { listSessionDates } = await import("./session-store-3BRPGC6P.js");
|
|
854
|
+
const sessionDates = listSessionDates();
|
|
855
|
+
const unconsolidated = [];
|
|
856
|
+
for (const date of sessionDates) {
|
|
857
|
+
if (unconsolidated.length >= (limit ?? 30)) break;
|
|
858
|
+
if (!isDayConsolidated(date)) {
|
|
859
|
+
unconsolidated.push(date);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
return unconsolidated;
|
|
863
|
+
}
|
|
864
|
+
|
|
670
865
|
// ../chitragupta/packages/smriti/src/day-consolidation.ts
|
|
671
866
|
function getDaysRoot() {
|
|
672
|
-
return
|
|
867
|
+
return path2.join(getChitraguptaHome(), "days");
|
|
673
868
|
}
|
|
674
869
|
function getDayFilePath(date) {
|
|
675
870
|
const match = date.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
676
871
|
if (!match) throw new SessionError(`Invalid date: ${date}. Expected YYYY-MM-DD.`);
|
|
677
|
-
return
|
|
872
|
+
return path2.join(getDaysRoot(), match[1], match[2], `${match[3]}.md`);
|
|
678
873
|
}
|
|
679
874
|
async function consolidateDay(date, options) {
|
|
680
875
|
const t0 = performance.now();
|
|
681
876
|
const dayPath = getDayFilePath(date);
|
|
682
|
-
if (!options?.force &&
|
|
683
|
-
const content =
|
|
877
|
+
if (!options?.force && fs2.existsSync(dayPath)) {
|
|
878
|
+
const content = fs2.readFileSync(dayPath, "utf-8");
|
|
684
879
|
const sessionCount = (content.match(/^### Session:/gm) || []).length;
|
|
685
880
|
return {
|
|
686
881
|
date,
|
|
@@ -696,7 +891,7 @@ async function consolidateDay(date, options) {
|
|
|
696
891
|
if (options?.loadSessions) {
|
|
697
892
|
sessions = await options.loadSessions(date);
|
|
698
893
|
} else {
|
|
699
|
-
const { listSessionsByDate, listTurnsWithTimestamps, loadSession } = await import("./session-store-
|
|
894
|
+
const { listSessionsByDate, listTurnsWithTimestamps, loadSession } = await import("./session-store-3BRPGC6P.js");
|
|
700
895
|
const metas = listSessionsByDate(date);
|
|
701
896
|
sessions = metas.map((meta) => {
|
|
702
897
|
try {
|
|
@@ -767,11 +962,11 @@ async function consolidateDay(date, options) {
|
|
|
767
962
|
}
|
|
768
963
|
const extractedFacts = await extractFactsWithEngine(sessions);
|
|
769
964
|
const markdown = generateDayMarkdown(date, projectMap, sessions.length, totalTurns, extractedFacts);
|
|
770
|
-
const dir =
|
|
771
|
-
|
|
772
|
-
|
|
965
|
+
const dir = path2.dirname(dayPath);
|
|
966
|
+
fs2.mkdirSync(dir, { recursive: true });
|
|
967
|
+
fs2.writeFileSync(dayPath, markdown, "utf-8");
|
|
773
968
|
try {
|
|
774
|
-
const { indexConsolidationSummary } = await import("./consolidation-indexer-
|
|
969
|
+
const { indexConsolidationSummary } = await import("./consolidation-indexer-VKQ6DNU3.js");
|
|
775
970
|
await indexConsolidationSummary("daily", date, markdown);
|
|
776
971
|
} catch {
|
|
777
972
|
}
|
|
@@ -832,198 +1027,22 @@ function extractFactsFallback(sessions) {
|
|
|
832
1027
|
}
|
|
833
1028
|
return [...new Set(facts)];
|
|
834
1029
|
}
|
|
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
1030
|
|
|
1014
1031
|
export {
|
|
1015
|
-
detectSessionType,
|
|
1016
1032
|
getExtractorStrategy,
|
|
1033
|
+
detectSessionType,
|
|
1017
1034
|
extractEventChain,
|
|
1018
1035
|
FactExtractor,
|
|
1019
1036
|
getFactExtractor,
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
consolidateDay,
|
|
1037
|
+
generateDayMarkdown,
|
|
1038
|
+
eventIcon,
|
|
1023
1039
|
readDayFile,
|
|
1024
1040
|
listDayFiles,
|
|
1025
1041
|
searchDayFiles,
|
|
1026
1042
|
isDayConsolidated,
|
|
1027
|
-
getUnconsolidatedDates
|
|
1043
|
+
getUnconsolidatedDates,
|
|
1044
|
+
getDaysRoot,
|
|
1045
|
+
getDayFilePath,
|
|
1046
|
+
consolidateDay
|
|
1028
1047
|
};
|
|
1029
|
-
//# sourceMappingURL=chunk-
|
|
1048
|
+
//# sourceMappingURL=chunk-77725AR7.js.map
|