feat(zed): automatic memory for the Zed editor's AI assistant#2153
Open
DK09876 wants to merge 9 commits into
Open
feat(zed): automatic memory for the Zed editor's AI assistant#2153DK09876 wants to merge 9 commits into
DK09876 wants to merge 9 commits into
Conversation
… real Zed) Core of the Zed integration, both validated against a real Zed install: - threads_db.py: reads Zed's SQLite threads.db (all 4 on-disk formats, zstd streaming frames, folder_paths->project). Caught/fixed a real zstd frame bug that synthetic fixtures had masked. - rules_file.py: writes a fenced HINDSIGHT memory block into the instruction file Zed actually reads (.rules / AGENTS.md / ...), without hijacking a user's existing file. Verified Zed auto-injects it into every conversation. 27 unit tests; reader additionally verified against a live threads.db.
Completes the Zed integration: a background daemon (launchd/systemd) that polls Zed's threads.db and, per project, keeps a recalled-memory block fresh in the instruction file Zed always reads (auto-recall) and retains conversations (auto-retain). Per-project banks by default. - daemon.py / state.py: poll -> recall -> write block; retain w/ dedup - client.py / config.py / bank.py / content.py: HTTP client, typed config, per-git-repo bank derivation, transcript+memory formatting - cli.py: hindsight-zed init/run/status/uninstall (launchd + systemd) - pyproject (hindsight-zed, zstandard runtime dep), README, settings.json - CI job + detect-changes filter, VALID_INTEGRATIONS, docs page + gallery entry - 58 deterministic tests + a gated requires_real_llm e2e; ruff clean Closes #2096
Replace the placeholder SVG with Zed's official logo (assets/images/zed_logo.svg from zed-industries/zed).
# Conflicts: # scripts/release-integration.sh
The /changelog/integrations/zed page is generated by the release script when a version is cut; linking it before release broke the docs build (broken link).
Recall/retain errors were swallowed at DEBUG, so a wrong API token or an unreachable server failed silently — the user just saw no memory in Zed with no hint why. Now auth (401/403) and connection/5xx errors escalate to WARNING in the daemon log, deduped per bank (the 5s poll loop won't spam) and re-armed on a later success. Client raises a typed HindsightHTTPError carrying the status code.
verify-generated-files runs 'ruff format' across the repo (separate from 'ruff check'); reformat the 5 files it rewrote so the no-uncommitted-changes gate passes.
Zed has no 'thread finished' event, so the daemon previously retained on every threads.db update — re-retaining the full transcript each turn and risking mid-stream snapshots. Add RetainDebouncer: a thread is retained once its updated_at has been stable for retain_idle_seconds (default 45s), collapsing a multi-turn conversation into a single retain of its settled state. Recall stays eager (memory should be as fresh as Zed allows); only retain is debounced. +3 tests (idle hold, timer reset on new revision, poll-level debounce).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2096 — a user requested a native, automatic Zed integration (like the OpenClaw / oh-my-openagent plugins), not the manual MCP path.
What it does
When you chat with Zed's Agent Panel, relevant memory from past sessions on that project is injected automatically — no manual tool calls — and conversations are retained so the next session builds on them. Per-project banks by default.
Why a daemon (and how it was validated)
Zed exposes no AI-conversation hook and no prompt-injection extension point (verified against
zed-industries/zedsource). The only always-on mechanism is Zed's instruction files (.rules/AGENTS.md/ …), which Zed includes in every conversation; transcripts live in a localthreads.db. Sohindsight-zedis a small background daemon (launchd/systemd) that:<!-- HINDSIGHT -->block in the instruction file Zed actually reads — without hijacking an existingAGENTS.md/CLAUDE.md(writes the block into that file instead of creating a higher-priority.rulesthat would suppress it).threads.dband retains transcripts.Both core assumptions were validated against a real Zed install before building:
threads.dbreader was run against a live database — which surfaced and fixed a real bug (Zed's zstd frames omit the content-size header, so one-shot decompress fails; the reader now streams). Synthetic fixtures had masked it..rulesauto-injection was confirmed end-to-end: a canary memory block showed up in a fresh Zed conversation with zero manual steps.Scope / packaging
--fixed-bank-idfor a shared bank.hindsight-zed init/run/status/uninstall. Runtime dep:zstandard(Zed compresses threads).0.3.0externally-tagged enums + 3 legacy shapes) and the bare-stringResumeedge case.Tests
threads.db+ fake client). Ruff clean.requires_real_llme2e (retain → recall roundtrip against a live server), excluded from PR CI.Known limitation
Zed has no per-prompt hook, so injection is periodic (refreshed on conversation update), not recomputed per keystroke. The relevant project memory is present in context every turn; it just isn't query-aware on the exact message instant — unavoidable in Zed today.