pi-hermes-memory 0.7.9 → 0.7.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/package.json +1 -1
- package/src/store/skill-utils.ts +23 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-hermes-memory",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.10",
|
|
4
4
|
"description": "🧠 Persistent memory + 🔍 session search + 🛡️ secret scanning for Pi. Token-aware policy-only memory by default, SQLite FTS5 search, auto-consolidation, procedural skills. 368 tests. Ported from Hermes agent.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
package/src/store/skill-utils.ts
CHANGED
|
@@ -6,6 +6,19 @@ export interface ParsedSkillFile {
|
|
|
6
6
|
body: string;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
function parseScalar(value: string): string {
|
|
10
|
+
const trimmed = value.trim();
|
|
11
|
+
if (trimmed.length >= 2 && trimmed.startsWith('"') && trimmed.endsWith('"')) {
|
|
12
|
+
try {
|
|
13
|
+
const parsed = JSON.parse(trimmed);
|
|
14
|
+
if (typeof parsed === "string") return parsed;
|
|
15
|
+
} catch {
|
|
16
|
+
// fall through to raw trimmed
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return trimmed;
|
|
20
|
+
}
|
|
21
|
+
|
|
9
22
|
export function parseFrontmatter(raw: string): ParsedSkillFile {
|
|
10
23
|
const match = raw.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
|
|
11
24
|
if (!match) return { meta: {}, body: raw.trim() };
|
|
@@ -15,7 +28,7 @@ export function parseFrontmatter(raw: string): ParsedSkillFile {
|
|
|
15
28
|
const idx = line.indexOf(":");
|
|
16
29
|
if (idx > 0) {
|
|
17
30
|
const key = line.slice(0, idx).trim();
|
|
18
|
-
const value = line.slice(idx + 1)
|
|
31
|
+
const value = parseScalar(line.slice(idx + 1));
|
|
19
32
|
meta[key] = value;
|
|
20
33
|
}
|
|
21
34
|
}
|
|
@@ -23,18 +36,22 @@ export function parseFrontmatter(raw: string): ParsedSkillFile {
|
|
|
23
36
|
return { meta, body: match[2].trim() };
|
|
24
37
|
}
|
|
25
38
|
|
|
39
|
+
function yamlDoubleQuoted(value: string): string {
|
|
40
|
+
return JSON.stringify(value);
|
|
41
|
+
}
|
|
42
|
+
|
|
26
43
|
export function formatFrontmatter(doc: Pick<SkillDocument, "name" | "displayName" | "description" | "version" | "created" | "updated" | "body">): string {
|
|
27
44
|
const lines = [
|
|
28
45
|
"---",
|
|
29
|
-
`name: ${doc.name}`,
|
|
30
|
-
`description: ${doc.description}`,
|
|
46
|
+
`name: ${yamlDoubleQuoted(doc.name)}`,
|
|
47
|
+
`description: ${yamlDoubleQuoted(doc.description)}`,
|
|
31
48
|
`version: ${doc.version}`,
|
|
32
|
-
`created: ${doc.created}`,
|
|
33
|
-
`updated: ${doc.updated}`,
|
|
49
|
+
`created: ${yamlDoubleQuoted(doc.created)}`,
|
|
50
|
+
`updated: ${yamlDoubleQuoted(doc.updated)}`,
|
|
34
51
|
];
|
|
35
52
|
|
|
36
53
|
if (doc.displayName && doc.displayName.trim() && doc.displayName.trim() !== doc.name) {
|
|
37
|
-
lines.push(`display_name: ${doc.displayName.trim()}`);
|
|
54
|
+
lines.push(`display_name: ${yamlDoubleQuoted(doc.displayName.trim())}`);
|
|
38
55
|
}
|
|
39
56
|
|
|
40
57
|
lines.push("---", doc.body);
|