fix: improve merge logic, time decay, breath output format, session hook
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
# OMBRE_HOOK_SKIP — set to "1" to disable the hook temporarily
|
||||
# ============================================================
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import urllib.request
|
||||
@@ -28,35 +27,18 @@ def main():
|
||||
|
||||
base_url = os.environ.get("OMBRE_HOOK_URL", "http://localhost:8000").rstrip("/")
|
||||
|
||||
# Build MCP call via HTTP POST to the streamable-http endpoint
|
||||
# The breath tool with no query triggers surfacing mode.
|
||||
payload = json.dumps({
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"method": "tools/call",
|
||||
"params": {
|
||||
"name": "breath",
|
||||
"arguments": {"query": "", "max_results": 2}
|
||||
}
|
||||
}).encode("utf-8")
|
||||
|
||||
req = urllib.request.Request(
|
||||
f"{base_url}/mcp",
|
||||
data=payload,
|
||||
headers={"Content-Type": "application/json"},
|
||||
method="POST",
|
||||
f"{base_url}/breath-hook",
|
||||
headers={"Accept": "text/plain"},
|
||||
method="GET",
|
||||
)
|
||||
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=8) as response:
|
||||
raw = response.read().decode("utf-8")
|
||||
data = json.loads(raw)
|
||||
# Extract text from MCP tool result
|
||||
result_content = data.get("result", {}).get("content", [])
|
||||
text_parts = [c.get("text", "") for c in result_content if c.get("type") == "text"]
|
||||
output = "\n".join(text_parts).strip()
|
||||
if output and output != "权重池平静,没有需要处理的记忆。":
|
||||
print(f"[Ombre Brain - 记忆浮现]\n{output}")
|
||||
output = raw.strip()
|
||||
if output:
|
||||
print(output)
|
||||
except (urllib.error.URLError, OSError):
|
||||
# Server not available (local stdio mode or not running) — silent fail
|
||||
pass
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
{
|
||||
"type": "command",
|
||||
"command": "python \"$CLAUDE_PROJECT_DIR/.claude/hooks/session_breath.py\"",
|
||||
"shell": "powershell",
|
||||
"shell": "/bin/bash",
|
||||
"timeout": 12,
|
||||
"statusMessage": "Ombre Brain 正在浮现记忆..."
|
||||
}
|
||||
@@ -19,7 +19,7 @@
|
||||
{
|
||||
"type": "command",
|
||||
"command": "python \"$CLAUDE_PROJECT_DIR/.claude/hooks/session_breath.py\"",
|
||||
"shell": "powershell",
|
||||
"shell": "/bin/bash",
|
||||
"timeout": 12,
|
||||
"statusMessage": "Ombre Brain 正在浮现记忆..."
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user