@oh-my-pi/pi-mnemopi 16.3.7 → 16.3.9
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/CHANGELOG.md +6 -0
- package/package.json +4 -4
- package/src/core/extraction.ts +33 -7
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [16.3.9] - 2026-07-06
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- Fixed extractor JSON parsing to correctly unwrap object-shaped facts, instructions, preferences, and timeline items from known text fields instead of persisting literal `[object Object]` rows.
|
|
10
|
+
|
|
5
11
|
## [16.3.7] - 2026-07-05
|
|
6
12
|
|
|
7
13
|
### Added
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@oh-my-pi/pi-mnemopi",
|
|
4
|
-
"version": "16.3.
|
|
4
|
+
"version": "16.3.9",
|
|
5
5
|
"description": "Local SQLite memory engine for Oh My Pi agents",
|
|
6
6
|
"homepage": "https://omp.sh",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"fmt": "biome format --write ."
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@oh-my-pi/pi-ai": "16.3.
|
|
43
|
-
"@oh-my-pi/pi-catalog": "16.3.
|
|
44
|
-
"@oh-my-pi/pi-utils": "16.3.
|
|
42
|
+
"@oh-my-pi/pi-ai": "16.3.9",
|
|
43
|
+
"@oh-my-pi/pi-catalog": "16.3.9",
|
|
44
|
+
"@oh-my-pi/pi-utils": "16.3.9",
|
|
45
45
|
"lru-cache": "11.5.1"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
package/src/core/extraction.ts
CHANGED
|
@@ -85,6 +85,10 @@ function stripFence(raw: string): string {
|
|
|
85
85
|
const FLAT_FACT_LIMIT = 5;
|
|
86
86
|
const STRUCTURED_CATEGORY_LIMIT = 5;
|
|
87
87
|
const STRING_CATEGORY_KEYS = ["facts", "instructions", "preferences", "timelines"] as const;
|
|
88
|
+
const FACT_TEXT_FIELD_KEYS = ["fact", "text", "content", "value", "statement"] as const;
|
|
89
|
+
const INSTRUCTION_TEXT_FIELD_KEYS = ["instruction", "rule", ...FACT_TEXT_FIELD_KEYS] as const;
|
|
90
|
+
const PREFERENCE_TEXT_FIELD_KEYS = ["preference", ...FACT_TEXT_FIELD_KEYS] as const;
|
|
91
|
+
const TIMELINE_TEXT_FIELD_KEYS = ["description", "event", "timeline", "date", ...FACT_TEXT_FIELD_KEYS] as const;
|
|
88
92
|
|
|
89
93
|
/** Parsed knowledge-graph edge emitted by the extractor LLM. */
|
|
90
94
|
export interface ExtractedKgTriple {
|
|
@@ -112,14 +116,36 @@ function normalizeFact(fact: string): string {
|
|
|
112
116
|
return trimmed.replace(/[.!?]+$/, "");
|
|
113
117
|
}
|
|
114
118
|
|
|
115
|
-
|
|
119
|
+
interface FactArrayOptions {
|
|
120
|
+
fields: readonly string[];
|
|
121
|
+
joinFields?: boolean;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function normalizeFactArray(items: unknown, options: FactArrayOptions): string[] {
|
|
116
125
|
if (!Array.isArray(items)) {
|
|
117
126
|
return [];
|
|
118
127
|
}
|
|
119
128
|
const out: string[] = [];
|
|
120
129
|
for (const item of items) {
|
|
121
|
-
|
|
122
|
-
|
|
130
|
+
let text: string | null = null;
|
|
131
|
+
if (typeof item === "string") {
|
|
132
|
+
text = item.trim();
|
|
133
|
+
} else if (isRecord(item)) {
|
|
134
|
+
const parts: string[] = [];
|
|
135
|
+
for (const key of options.fields) {
|
|
136
|
+
const candidate = item[key];
|
|
137
|
+
if (typeof candidate === "string") {
|
|
138
|
+
const trimmed = candidate.trim();
|
|
139
|
+
if (trimmed !== "") {
|
|
140
|
+
parts.push(trimmed);
|
|
141
|
+
if (options.joinFields !== true) break;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
text = parts.length > 0 ? parts.join(" ") : null;
|
|
146
|
+
}
|
|
147
|
+
if (text !== null && text !== "") {
|
|
148
|
+
const normalized = normalizeFact(text);
|
|
123
149
|
if (normalized !== "") {
|
|
124
150
|
out.push(normalized);
|
|
125
151
|
if (out.length >= STRUCTURED_CATEGORY_LIMIT) break;
|
|
@@ -205,10 +231,10 @@ export function parseExtractedFactCategories(rawOutput: string | null | undefine
|
|
|
205
231
|
const parsed: unknown = JSON.parse(rawClean);
|
|
206
232
|
if (isRecord(parsed)) {
|
|
207
233
|
return {
|
|
208
|
-
facts: normalizeFactArray(parsed.facts),
|
|
209
|
-
instructions: normalizeFactArray(parsed.instructions),
|
|
210
|
-
preferences: normalizeFactArray(parsed.preferences),
|
|
211
|
-
timelines: normalizeFactArray(parsed.timelines),
|
|
234
|
+
facts: normalizeFactArray(parsed.facts, { fields: FACT_TEXT_FIELD_KEYS }),
|
|
235
|
+
instructions: normalizeFactArray(parsed.instructions, { fields: INSTRUCTION_TEXT_FIELD_KEYS }),
|
|
236
|
+
preferences: normalizeFactArray(parsed.preferences, { fields: PREFERENCE_TEXT_FIELD_KEYS }),
|
|
237
|
+
timelines: normalizeFactArray(parsed.timelines, { fields: TIMELINE_TEXT_FIELD_KEYS, joinFields: true }),
|
|
212
238
|
kg: normalizeKgArray(parsed.kg),
|
|
213
239
|
};
|
|
214
240
|
}
|