claude-recall 0.36.1 → 0.36.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/dist/cli/claude-recall-cli.js +32 -10
- package/package.json +1 -1
|
@@ -795,22 +795,44 @@ class ClaudeRecallCLI {
|
|
|
795
795
|
}
|
|
796
796
|
/**
|
|
797
797
|
* Pull the human-readable text out of a memory value, whether it's a raw
|
|
798
|
-
* string, a JSON string, or a structured object
|
|
798
|
+
* string, a JSON string, or a structured object. Failure memories nest their
|
|
799
|
+
* payload as an OBJECT under `content` ({ what_failed, why_failed, ... }), so
|
|
800
|
+
* a naive `String(value.content)` renders "[object Object]" — unwrap nested
|
|
801
|
+
* content/value/text wrappers and surface the failure gist instead.
|
|
799
802
|
*/
|
|
800
803
|
extractContent(value) {
|
|
801
804
|
let v = value;
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
+
// Descend through nested wrappers. The payload can be an object, a JSON
|
|
806
|
+
// string, or an object whose content/value/text is itself a JSON string
|
|
807
|
+
// (failure memories come in both shapes) — so parse-as-we-go, bounded.
|
|
808
|
+
for (let depth = 0; depth < 6; depth++) {
|
|
809
|
+
if (typeof v === 'string') {
|
|
810
|
+
const t = v.trim();
|
|
811
|
+
if (t.startsWith('{') || t.startsWith('[')) {
|
|
812
|
+
try {
|
|
813
|
+
v = JSON.parse(t);
|
|
814
|
+
continue;
|
|
815
|
+
}
|
|
816
|
+
catch {
|
|
817
|
+
return v;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
return v;
|
|
805
821
|
}
|
|
806
|
-
|
|
807
|
-
|
|
822
|
+
if (v && typeof v === 'object' && !Array.isArray(v)) {
|
|
823
|
+
// Failure-shaped object: show what broke → what to do instead.
|
|
824
|
+
if (typeof v.what_failed === 'string') {
|
|
825
|
+
return v.what_should_do ? `${v.what_failed} → ${v.what_should_do}` : v.what_failed;
|
|
826
|
+
}
|
|
827
|
+
const next = v.content ?? v.value ?? v.text;
|
|
828
|
+
if (next === undefined)
|
|
829
|
+
return JSON.stringify(v);
|
|
830
|
+
v = next;
|
|
831
|
+
continue;
|
|
808
832
|
}
|
|
833
|
+
break;
|
|
809
834
|
}
|
|
810
|
-
|
|
811
|
-
return String(v.content ?? v.value ?? v.text ?? JSON.stringify(v));
|
|
812
|
-
}
|
|
813
|
-
return String(v);
|
|
835
|
+
return typeof v === 'string' ? v : JSON.stringify(v);
|
|
814
836
|
}
|
|
815
837
|
/**
|
|
816
838
|
* Export memories to a file
|
package/package.json
CHANGED