[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-79904":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":8,"htmlUrl":8,"language":9,"languages":8,"totalLinesOfCode":8,"stars":10,"forks":11,"watchers":12,"openIssues":13,"contributorsCount":14,"subscribersCount":14,"size":14,"stars1d":15,"stars7d":15,"stars30d":15,"stars90d":14,"forks30d":14,"starsTrendScore":16,"compositeScore":17,"rankGlobal":8,"rankLanguage":8,"license":8,"archived":18,"fork":18,"defaultBranch":19,"hasWiki":20,"hasPages":18,"topics":21,"createdAt":8,"pushedAt":8,"updatedAt":22,"readmeContent":23,"aiSummary":24,"trendingCount":14,"starSnapshotCount":14,"syncStatus":25,"lastSyncTime":26,"discoverSource":27},79904,"agent-memory-hooks-neo4j","tomasonjo\u002Fagent-memory-hooks-neo4j","tomasonjo",null,"Python",95,20,91,1,0,3,9,3.97,false,"main",true,[],"2026-06-12 02:03:55","# Agent Memory Hooks (Claude Code + Codex + Cursor)\n\nA two-stage memory system for [Claude Code](https:\u002F\u002Fclaude.com\u002Fclaude-code),\n[Codex](https:\u002F\u002Fdevelopers.openai.com\u002Fcodex\u002Fhooks), and\n[Cursor](https:\u002F\u002Fwww.cursor.com\u002F), backed by Neo4j.\n\n1. **Hooks (online)** — capture every session event from either agent into a\n   shared graph as it happens.\n2. **Dream phase (offline)** — periodically read those events and distill\n   them into durable, markdown-style memories that future sessions can use.\n\nThe hooks record *what happened*. The dream phase decides *what's worth\nremembering*. Both clients write into the same Neo4j instance; nodes are\ntagged with `client: \"claude_code\" | \"codex\" | \"cursor\"` so you can query\nacross or within agents.\n\n## Repo layout\n\n```\nhooks\u002F\n  log_event.py             # shared writer (takes --client)\n  inject_memory.py         # shared memory injector\n.claude\u002F\n  settings.json            # registers hooks with Claude Code\n  hooks\u002F\n    log_event.sh           # → hooks\u002Flog_event.py --client claude_code\n    inject_memory.sh       # → hooks\u002Finject_memory.py --client claude_code\n.codex\u002F\n  hooks.json               # registers hooks with Codex\n  hooks\u002F\n    log_event.sh           # → hooks\u002Flog_event.py --client codex\n    inject_memory.sh       # → hooks\u002Finject_memory.py --client codex\n.cursor\u002F\n  hooks.json               # modern Cursor hook registration\n  settings.json            # legacy\u002Fcompat Cursor hook registration\n  hooks\u002F\n    log_event.sh           # → hooks\u002Flog_event.py --client cursor\n    inject_memory.sh       # → hooks\u002Finject_memory.py --client cursor\ndream\u002F\n  dream.py                 # offline consolidation script\n  README.md                # dream-phase docs\n  requirements.txt\nrequirements.txt           # hook deps (just neo4j driver)\ntest_hooks.py              # smoke test for the hook writer\n```\n\n## Stage 1 — Hooks\n\nEach session (Claude Code, Codex, or Cursor) becomes a linked list of events:\n\n```\n(Session {session_id, client}) -[:FIRST_EVENT]->  (Event) -[:NEXT]-> (Event) -> ...\n                               -[:LATEST_EVENT]-> (last Event)\n```\n\nEvents captured: `SessionStart`, `UserPromptSubmit`, `PreToolUse`,\n`PostToolUse`, `Stop`. Codex also exposes `PermissionRequest` (not currently\nwired up). Each `:Event` stores the raw hook payload — prompt, tool name,\ntool input, tool response, transcript snapshot, plus Codex-specific\n`turn_id` \u002F `tool_use_id` \u002F `last_assistant_message` when present.\n\n### Setup\n\n```bash\npip install -r requirements.txt\n# defaults assume bolt:\u002F\u002Flocalhost:7687 with neo4j\u002Fpassword\nexport HOOKS_NEO4J_URI=bolt:\u002F\u002Flocalhost:7687\nexport HOOKS_NEO4J_USER=neo4j\nexport HOOKS_NEO4J_PASSWORD=password\n```\n\nThe hooks are already wired up:\n- **Claude Code**: `.claude\u002Fsettings.json` — run Claude Code from this dir.\n- **Codex**: `.codex\u002Fhooks.json` — run Codex from this dir with\n  `[features] codex_hooks = true` enabled in `~\u002F.codex\u002Fconfig.toml`.\n- **Cursor**: `.cursor\u002Fhooks.json` (preferred) or `.cursor\u002Fsettings.json`\n  (legacy compatibility) — open this dir in Cursor.\n\nFor Python dependencies, Cursor wrappers prefer `.\u002F.venv\u002Fbin\u002Fpython` and\nfallback to `python3`. This avoids interpreter mismatches when Cursor runs in\na different environment than your shell.\n\nBoth clients stream events into the same Neo4j instance; Session\u002FEvent nodes\nare tagged with the originating `client`.\n\n### Test\n\n```bash\npython test_hooks.py    # requires a running Neo4j\n```\n\n## Stage 2 — Dream phase\n\nReads sessions that have events newer than their `last_dreamed_at`\nwatermark, asks Claude to extract durable memories, and upserts them as\n`:Memory` nodes whose `path` + `content` imitate a markdown file.\n\n```bash\npip install -r dream\u002Frequirements.txt\nexport ANTHROPIC_API_KEY=sk-ant-...\n\npython dream\u002Fdream.py              # all sessions with new events\npython dream\u002Fdream.py --since 24h  # only events from last 24h\npython dream\u002Fdream.py --dry-run    # preview without writing\n```\n\nMemory paths are organized semantically:\n\n```\nprofile\u002Frole.md\nprofile\u002Fpreferences.md\ntools\u002Fbash\u002Fcommon-flags.md\nproject\u002F\u003Cslug>.md\ngeneral\u002F\u003Cslug>.md\n```\n\nSee [dream\u002FREADME.md](dream\u002FREADME.md) for full docs (schema, re-run\nbehavior, inspect\u002Freset queries).\n\n## Full graph schema\n\n```\n(:Session {session_id, client, created_at, last_dreamed_at})\n  -[:FIRST_EVENT]->  (:Event)\n  -[:LATEST_EVENT]-> (:Event)\n  -[:DREAMED]->      (:Memory)\n\n(:Event {event_id, event_name, client, timestamp, tool_name, tool_input,\n         tool_use_id, tool_response, prompt, model, source, turn_id,\n         last_assistant_message, stop_hook_active, transcript_path,\n         transcript, cwd})\n  -[:NEXT]-> (:Event)\n\n(:Memory {path, content, updated_at})              \u002F\u002F path unique\n  -[:DERIVED_FROM]-> (:Session)\n```\n\n## Suggested workflow\n\n1. Use Claude Code as normal — hooks capture everything.\n2. Run `python dream\u002Fdream.py` on a cadence that suits you (manually,\n   nightly cron, or after each session).\n3. Future sessions \u002F agents can read `:Memory` nodes by path to get a fast\n   profile of who the user is, what tools work well, and what's going on\n   in the project.\n","该项目是一个基于Neo4j的两阶段记忆系统，旨在为Claude Code、Codex和Cursor等代理工具提供在线事件捕捉与离线记忆提炼功能。核心功能包括实时捕获会话事件并存储到共享图数据库中，以及定期将这些事件提炼成持久化的Markdown格式记忆供后续会话使用。技术上，通过Python脚本实现事件记录，并利用Neo4j的强大图数据存储能力来组织和查询这些信息。适用于需要跨平台整合开发环境活动日志，并希望从中提取有价值见解的场景，比如开发者工具集成、代码辅助学习或项目历史回顾等领域。",2,"2026-06-11 03:58:29","CREATED_QUERY"]