mirror of
https://github.com/garrytan/gstack.git
synced 2026-07-08 17:18:16 +02:00
feat: bidirectional learnings bridge — gstack writes OpenClaw memory files
When ~/.openclaw/ exists, gstack-learnings-log writes a parallel markdown
copy to ~/.openclaw/workspace/memory/gstack-{slug}.md. OpenClaw agents
can read these directly as memory entries.
gstack-learnings-search reads back from OpenClaw memory files (*.md in
~/.openclaw/workspace/memory/) and includes them in unified search
results alongside native JSONL learnings. Cross-pollination.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -38,7 +38,31 @@ if [ "$CROSS_PROJECT" = true ]; then
|
||||
done
|
||||
fi
|
||||
|
||||
# Also read OpenClaw memory files (bidirectional bridge)
|
||||
OPENCLAW_MEM="$HOME/.openclaw/workspace/memory"
|
||||
if [ -d "$OPENCLAW_MEM" ]; then
|
||||
for f in $(find "$OPENCLAW_MEM" -name "*.md" -not -name "gstack-*" 2>/dev/null | head -10); do
|
||||
# Convert markdown memory entries to JSONL for unified processing
|
||||
# Only parse lines that look like learnings (start with "- ")
|
||||
bun -e "
|
||||
const text = await Bun.file('$f').text();
|
||||
for (const line of text.split('\n')) {
|
||||
const m = line.match(/^- \\*\\*\\[([^\\]]+)\\]\\*\\*.*?\\(([^,]+),.*?confidence: (\\d+)/);
|
||||
if (m) {
|
||||
console.log(JSON.stringify({
|
||||
key: m[1], type: m[2].trim(), confidence: parseInt(m[3]),
|
||||
insight: line.replace(/^- \\*\\*\\[[^\\]]+\\]\\*\\*[^:]*: /, ''),
|
||||
source: 'openclaw', ts: new Date().toISOString()
|
||||
}));
|
||||
}
|
||||
}
|
||||
" 2>/dev/null >> /tmp/gstack-openclaw-learnings-$$.jsonl || true
|
||||
done
|
||||
[ -f "/tmp/gstack-openclaw-learnings-$$.jsonl" ] && FILES+=("/tmp/gstack-openclaw-learnings-$$.jsonl")
|
||||
fi
|
||||
|
||||
if [ ${#FILES[@]} -eq 0 ]; then
|
||||
rm -f /tmp/gstack-openclaw-learnings-$$.jsonl 2>/dev/null
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -129,3 +153,6 @@ for (const [t, arr] of Object.entries(byType)) {
|
||||
console.log('');
|
||||
}
|
||||
" 2>/dev/null || exit 0
|
||||
|
||||
# Cleanup temp files
|
||||
rm -f /tmp/gstack-openclaw-learnings-$$.jsonl 2>/dev/null || true
|
||||
|
||||
Reference in New Issue
Block a user