@voidwire/lore 1.1.0 → 1.1.2
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/lib/indexers/personal.ts +26 -18
- package/package.json +1 -1
package/lib/indexers/personal.ts
CHANGED
|
@@ -25,38 +25,38 @@ function toISO(dateStr: string, fallback: string): string {
|
|
|
25
25
|
return s.includes("T") ? s : `${s.slice(0, 10)}T00:00:00Z`;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
const ENRICH_SHARED = `Only expand from the information provided. Do not add names, dates, or facts not present in the input.
|
|
29
|
+
Include both singular and plural forms where applicable.
|
|
30
|
+
Keep under 80 words. Output only the description, no headers or formatting.`;
|
|
31
|
+
|
|
28
32
|
const ENRICH_PROMPTS: Record<string, string> = {
|
|
29
33
|
person: `You are enriching a personal contact entry for search indexing.
|
|
30
34
|
The "relationship" field is the EXACT relationship — do NOT add other relationship types.
|
|
31
35
|
Generate synonyms and alternative phrasings ONLY for the stated relationship.
|
|
32
36
|
Example: relationship "uncle" → uncle, family member, relative, parent's brother, parent's sibling. NOT: cousin, nephew, aunt.
|
|
33
37
|
Example: relationship "daughter" → daughter, child, kid, offspring, family member. NOT: son, niece, nephew.
|
|
34
|
-
|
|
35
|
-
Keep under 80 words. Output only the description, no headers or formatting.`,
|
|
38
|
+
${ENRICH_SHARED}`,
|
|
36
39
|
book: `You are enriching a book entry for search indexing.
|
|
37
|
-
Generate: genre, themes,
|
|
38
|
-
|
|
39
|
-
Keep under 80 words. Output only the description, no headers or formatting.`,
|
|
40
|
+
Generate: genre, themes, and related topics based on the title.
|
|
41
|
+
${ENRICH_SHARED}`,
|
|
40
42
|
movie: `You are enriching a movie entry for search indexing.
|
|
41
|
-
Generate: genre, themes,
|
|
42
|
-
|
|
43
|
-
Keep under 80 words. Output only the description, no headers or formatting.`,
|
|
43
|
+
Generate: genre, themes, and related topics based on the title.
|
|
44
|
+
${ENRICH_SHARED}`,
|
|
44
45
|
interest: `You are enriching a personal interest entry for search indexing.
|
|
45
46
|
Generate: related activities, domains, synonyms, and common alternative phrasings.
|
|
46
|
-
|
|
47
|
-
Keep under 80 words. Output only the description, no headers or formatting.`,
|
|
47
|
+
${ENRICH_SHARED}`,
|
|
48
48
|
habit: `You are enriching a personal habit/routine entry for search indexing.
|
|
49
49
|
Generate: related routines, synonyms, categories, and common alternative phrasings.
|
|
50
|
-
|
|
51
|
-
Keep under 80 words. Output only the description, no headers or formatting.`,
|
|
50
|
+
${ENRICH_SHARED}`,
|
|
52
51
|
};
|
|
53
52
|
|
|
54
|
-
const ENRICH_TIMEOUT_MS =
|
|
53
|
+
const ENRICH_TIMEOUT_MS = 30_000;
|
|
54
|
+
const ENRICH_MAX_FAILURES = 3;
|
|
55
55
|
|
|
56
|
-
let
|
|
56
|
+
let enrichmentFailures = 0;
|
|
57
57
|
|
|
58
58
|
async function enrich(type: string, input: string): Promise<string | null> {
|
|
59
|
-
if (
|
|
59
|
+
if (enrichmentFailures >= ENRICH_MAX_FAILURES) return null;
|
|
60
60
|
const systemPrompt = ENRICH_PROMPTS[type];
|
|
61
61
|
if (!systemPrompt) return null;
|
|
62
62
|
try {
|
|
@@ -74,16 +74,24 @@ async function enrich(type: string, input: string): Promise<string | null> {
|
|
|
74
74
|
),
|
|
75
75
|
),
|
|
76
76
|
]);
|
|
77
|
+
enrichmentFailures = 0;
|
|
77
78
|
return result.text.replace(/<\|[^|]+\|>/g, "").trim();
|
|
78
79
|
} catch (e) {
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
enrichmentFailures++;
|
|
81
|
+
console.warn(
|
|
82
|
+
`Enrichment failed (${enrichmentFailures}/${ENRICH_MAX_FAILURES}): ${e}`,
|
|
83
|
+
);
|
|
84
|
+
if (enrichmentFailures >= ENRICH_MAX_FAILURES) {
|
|
85
|
+
console.warn(
|
|
86
|
+
"Max enrichment failures reached, disabling for remaining entries",
|
|
87
|
+
);
|
|
88
|
+
}
|
|
81
89
|
return null;
|
|
82
90
|
}
|
|
83
91
|
}
|
|
84
92
|
|
|
85
93
|
export async function indexPersonal(ctx: IndexerContext): Promise<void> {
|
|
86
|
-
|
|
94
|
+
enrichmentFailures = 0;
|
|
87
95
|
const personalDir = ctx.config.paths.personal;
|
|
88
96
|
|
|
89
97
|
if (!checkPath("personal", "paths.personal", personalDir)) return;
|