mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-20 03:12:28 +08: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:
@@ -28,3 +28,24 @@ if ! printf '%s' "$INPUT" | bun -e "const j=JSON.parse(await Bun.stdin.text());
|
||||
fi
|
||||
|
||||
echo "$INPUT" >> "$GSTACK_HOME/projects/$SLUG/learnings.jsonl"
|
||||
|
||||
# OpenClaw bridge: write a parallel copy as OpenClaw-readable memory
|
||||
OPENCLAW_MEM="$HOME/.openclaw/workspace/memory"
|
||||
if [ -d "$HOME/.openclaw" ]; then
|
||||
mkdir -p "$OPENCLAW_MEM"
|
||||
MEM_FILE="$OPENCLAW_MEM/gstack-${SLUG}.md"
|
||||
# Extract fields for the memory entry
|
||||
ENTRY=$(printf '%s' "$INPUT" | bun -e "
|
||||
const j = JSON.parse(await Bun.stdin.text());
|
||||
const ts = j.ts || new Date().toISOString();
|
||||
const date = ts.split('T')[0];
|
||||
console.log('- **[' + (j.key||'unknown') + ']** (' + (j.type||'unknown') + ', ' + date + ', confidence: ' + (j.confidence||'?') + '/10): ' + (j.insight||''));
|
||||
" 2>/dev/null) || true
|
||||
if [ -n "$ENTRY" ]; then
|
||||
# Create file with header if it doesn't exist
|
||||
if [ ! -f "$MEM_FILE" ]; then
|
||||
printf '# gstack learnings for %s\n\nAuto-synced from gstack coding sessions.\n\n' "$SLUG" > "$MEM_FILE"
|
||||
fi
|
||||
echo "$ENTRY" >> "$MEM_FILE"
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user