Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,41 @@ All notable changes to **tre-mem** are documented here. The format follows
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.11.0] — 2026-06-07

**Facts you can take back.** Memory was append-only — a graduated or pinned fact
could never be removed, even after PR feedback or QC proved it wrong. Now the
assistant (or you) can forget a fact, and the removal **propagates to the whole
team** through git. Plus a smoother first run and a SessionStart banner that shows
once, below claude-mem.

### Added

- **`unpin_fact` / `ungraduate_fact` MCP tools** (now **9** tools total) — the
inverse of `pin_fact` / `graduate_fact`. Removing a fact that was already shared
writes a **tombstone** to `.tre-mem/` so every teammate's clone drops it on the
next import. Correcting a fact = `ungraduate_fact` then `graduate_fact` the fixed
observation. Same model as before: removal is local + pending until
`export_memory` (or `tre share`) publishes it.
- **`tre unpin` / `tre ungraduate` CLI** — terminal parity with the MCP tools.
- **Tombstone sync record** — a new append-only `.tre-mem/` line kind that carries
the `content_hash` of the removed fact. Kept at sync schema v1: pre-v0.11 clients
skip it gracefully (the fact simply lingers for them). Import applies tombstones
in a two-pass per file so a removal can never be resurrected by an earlier line.
- **`tre init --all`** — guided first run that wires every installed AI tool and
backfills past observations in one step, then prints clear next steps.
- **`tre doctor --fix-hooks`** — detects a tre-mem SessionStart hook registered in
more than one settings file (the cause of duplicate banners) and collapses it to
one.

### Changed

- **`tre status`** — regrouped into scannable **Identity / Memory / Tools /
claude-mem** sections with a headline `full` / `shared-only` mode.
- **SessionStart banner** — defers briefly (env-tunable `TRE_MEM_HOOK_DELAY_MS`,
default 250 ms when claude-mem is present) so it renders **below** claude-mem
instead of racing it. Combined with `--fix-hooks`, the banner shows exactly once.

## [0.10.0] — 2026-06-07

**The agent shares for you, and memory crosses your clones.** Two workflow gaps
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CLAUDE.md — Codebase Guide for Claude Code

> **Always read `PLAN.md` first.** It is the roadmap & status index — current version, what shipped, and the phase-SSOT chain. This file gives Claude orientation; `PLAN.md` gives the work. Current: **v0.10.0**. Phase SSOTs: `docs/plan/PLAN-PHASE2.md` (v0.2–0.4 team share), `docs/plan/PLAN-PHASE3.md` (v0.5 web dashboard), `docs/plan/PLAN-PHASE4.md` (v0.6 cross-tool), `docs/plan/PLAN-PHASE5.md` (v0.7 "share, made obvious"), `docs/plan/PLAN-PHASE6.md` (v0.8–0.9 bamboo identity + the Grove), `docs/plan/PLAN-PHASE7.md` (v0.10 agent-driven export + cross-clone memory).
> **Always read `PLAN.md` first.** It is the roadmap & status index — current version, what shipped, and the phase-SSOT chain. This file gives Claude orientation; `PLAN.md` gives the work. Current: **v0.11.0**. Phase SSOTs: `docs/plan/PLAN-PHASE2.md` (v0.2–0.4 team share), `docs/plan/PLAN-PHASE3.md` (v0.5 web dashboard), `docs/plan/PLAN-PHASE4.md` (v0.6 cross-tool), `docs/plan/PLAN-PHASE5.md` (v0.7 "share, made obvious"), `docs/plan/PLAN-PHASE6.md` (v0.8–0.9 bamboo identity + the Grove), `docs/plan/PLAN-PHASE7.md` (v0.10 agent-driven export + cross-clone memory), `docs/plan/PLAN-PHASE8.md` (v0.11 forget/correct facts via tombstones + onboarding/banner polish).

## What this project is

Expand Down
29 changes: 15 additions & 14 deletions PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@

## Current status

**Shipped: v0.10.0** — agent-driven export + cross-clone memory. Covered by
**366 tests**, green on Node 20 + 22. Releases are tracked in
[CHANGELOG.md](./CHANGELOG.md).

| Version | Theme | Phase SSOT |
| ---------- | ------------------------------------------------------------------------- | -------------------------------------------- |
| **v0.10** | Agent-driven `export_memory` + cross-clone memory union (by git remote) | [PLAN-PHASE7.md](./docs/plan/PLAN-PHASE7.md) |
| **v0.9** | "The Grove" — contributor graph + leaderboard + full Vietnamese i18n | [PLAN-PHASE6.md](./docs/plan/PLAN-PHASE6.md) |
| **v0.8** | Bamboo-green design identity (web + terminal), `docs/BRAND.md` SSOT | [PLAN-PHASE6.md](./docs/plan/PLAN-PHASE6.md) |
| **v0.7** | "Share, made obvious" — one-command `tre share`, local graduate-on-merge | [PLAN-PHASE5.md](./docs/plan/PLAN-PHASE5.md) |
| **v0.6** | Cross-tool — Codex / Gemini / Cursor / Antigravity via MCP | [PLAN-PHASE4.md](./docs/plan/PLAN-PHASE4.md) |
| **v0.5** | Local team dashboard (`tre web`) — branch graph + team memory, live (SSE) | [PLAN-PHASE3.md](./docs/plan/PLAN-PHASE3.md) |
| **v0.2–4** | Git-native team share — export/import, redaction, branch graduation | [PLAN-PHASE2.md](./docs/plan/PLAN-PHASE2.md) |
| **v0.1** | Branch-aware retrieval (3-signal rerank) + MCP server | Phase 1 (this file, § Phase 1 recap) |
**Shipped: v0.11.0** — forget/correct facts (propagating tombstones) + onboarding
& banner polish. Covered by **400+ tests**, green on Node 20 + 22. Releases are
tracked in [CHANGELOG.md](./CHANGELOG.md).

| Version | Theme | Phase SSOT |
| ---------- | -------------------------------------------------------------------------- | -------------------------------------------- |
| **v0.11** | Forget/correct facts via propagating tombstones + onboarding/banner polish | [PLAN-PHASE8.md](./docs/plan/PLAN-PHASE8.md) |
| **v0.10** | Agent-driven `export_memory` + cross-clone memory union (by git remote) | [PLAN-PHASE7.md](./docs/plan/PLAN-PHASE7.md) |
| **v0.9** | "The Grove" — contributor graph + leaderboard + full Vietnamese i18n | [PLAN-PHASE6.md](./docs/plan/PLAN-PHASE6.md) |
| **v0.8** | Bamboo-green design identity (web + terminal), `docs/BRAND.md` SSOT | [PLAN-PHASE6.md](./docs/plan/PLAN-PHASE6.md) |
| **v0.7** | "Share, made obvious" — one-command `tre share`, local graduate-on-merge | [PLAN-PHASE5.md](./docs/plan/PLAN-PHASE5.md) |
| **v0.6** | Cross-tool — Codex / Gemini / Cursor / Antigravity via MCP | [PLAN-PHASE4.md](./docs/plan/PLAN-PHASE4.md) |
| **v0.5** | Local team dashboard (`tre web`) — branch graph + team memory, live (SSE) | [PLAN-PHASE3.md](./docs/plan/PLAN-PHASE3.md) |
| **v0.2–4** | Git-native team share — export/import, redaction, branch graduation | [PLAN-PHASE2.md](./docs/plan/PLAN-PHASE2.md) |
| **v0.1** | Branch-aware retrieval (3-signal rerank) + MCP server | Phase 1 (this file, § Phase 1 recap) |

---

Expand Down
32 changes: 20 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ sees Stripe webhook chatter alongside JWT context. tre-mem fixes that:
- **History backfill** via `git reflog` so existing observations get a branch.
- **3-signal rerank**: semantic (FTS5/BM25), branch locality, recency-in-branch,
plus a `pin` boost for facts you want pinned to a branch.
- **MCP server** exposing 7 tools so Claude Code can call branch-aware
retrieval — and publish memory — directly.
- **MCP server** exposing 9 tools so Claude Code can call branch-aware
retrieval — and curate, publish, and retract memory — directly.

On the tre-mem repo itself the rerank lifts precision@10 from **0.19** (raw
FTS5 baseline) to **0.97**. See [BENCHMARK.md](./docs/BENCHMARK.md) for the harness.
Expand Down Expand Up @@ -95,7 +95,7 @@ CLI directly: `claude mcp add -s user tre-mem -- node /abs/path/to/tre-mem/dist/
Verify inside Claude Code with `/mcp`. You should see:

```
tre-mem · connected · 7 tools
tre-mem · connected · 9 tools
```

## Register the SessionStart hook (optional but recommended)
Expand Down Expand Up @@ -209,22 +209,30 @@ tre-mem search "stripe webhook"

## MCP tools

| Tool | Input | Output |
| --------------------- | ------------------------------------ | --------------------------------------------- |
| `get_branch_context` | `query`, `project?`, `branch?`, `k?` | Top-K observations, rerank breakdown included |
| `get_branch_timeline` | `branch`, `project?`, `limit?` | Chronological feed for a branch |
| `list_branches` | `project?` | Branches with tag counts |
| `pin_fact` | `observation_id`, `branch?`, `note?` | Pin a fact to a branch (boost = 1.0) |
| `graduate_fact` | `observation_id` | Promote a branch fact to project scope |
| `export_memory` | `branch?`, `all?`, `force?` | Write `.tre-mem/` + local commit (no push) |
| `get_share_status` | `project?` | Pending / shared / graduated counts |
| Tool | Input | Output |
| --------------------- | ------------------------------------ | ---------------------------------------------- |
| `get_branch_context` | `query`, `project?`, `branch?`, `k?` | Top-K observations, rerank breakdown included |
| `get_branch_timeline` | `branch`, `project?`, `limit?` | Chronological feed for a branch |
| `list_branches` | `project?` | Branches with tag counts |
| `pin_fact` | `observation_id`, `branch?`, `note?` | Pin a fact to a branch (boost = 1.0) |
| `graduate_fact` | `observation_id` | Promote a branch fact to project scope |
| `unpin_fact` | `observation_id`, `branch?` | Remove a pin (tombstones it if shared) |
| `ungraduate_fact` | `observation_id` | Remove a graduated fact (tombstones if shared) |
| `export_memory` | `branch?`, `all?`, `force?` | Write `.tre-mem/` + local commit (no push) |
| `get_share_status` | `project?` | Pending / shared / graduated counts |

After the assistant pins or graduates a fact, it can call **`export_memory`** to
publish it: this writes the `.tre-mem/` files and makes a **local git commit** — it
never pushes, so you review and `git push` when ready (the tool returns the exact
command). It's fail-closed on secrets: a blocked export reports the matched secret
_categories_, never the values.

When a fact goes stale — a leader's PR feedback, a bug found in QC — the assistant
calls **`unpin_fact`** or **`ungraduate_fact`** to take it back. If the fact was
already shared, this writes a **tombstone** to `.tre-mem/`; on the next `git pull`
every teammate's clone drops it automatically. To _correct_ a fact, ungraduate the
old one and `graduate_fact` the fixed observation.

## Cross-clone memory

If you clone the same repo into several directories (e.g. `app`, `app-2`, `app-3`)
Expand Down
31 changes: 20 additions & 11 deletions README.vi.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ Stripe webhook với JWT context. tre-mem xử lý điều đó:
- **Backfill lịch sử** qua `git reflog` để observation cũ cũng có branch.
- **Rerank 3-signal**: semantic (FTS5/BM25), branch locality, recency-trong-branch,
cộng thêm pin boost cho fact muốn ghim vào branch.
- **MCP server** expose 7 tool để Claude Code gọi retrieval branch-aware trực tiếp.
- **MCP server** expose 9 tool để Claude Code gọi retrieval branch-aware, đồng thời
curate, công bố và thu hồi memory — trực tiếp.

Trên chính repo tre-mem, rerank nâng precision@10 từ **0.19** (FTS5 baseline thuần)
lên **0.97**. Xem [BENCHMARK.md](./docs/BENCHMARK.md) để biết chi tiết harness.
Expand Down Expand Up @@ -93,7 +94,7 @@ claude mcp add -s user tre-mem -- tre mcp
Kiểm tra trong Claude Code bằng `/mcp`. Sẽ thấy:

```
tre-mem · connected · 7 tools
tre-mem · connected · 9 tools
```

## Đăng ký SessionStart hook (tùy chọn nhưng nên có)
Expand Down Expand Up @@ -205,22 +206,30 @@ tre-mem search "stripe webhook"

## MCP tools

| Tool | Input | Output |
| --------------------- | ------------------------------------ | -------------------------------------------- |
| `get_branch_context` | `query`, `project?`, `branch?`, `k?` | Top-K observations, kèm breakdown rerank |
| `get_branch_timeline` | `branch`, `project?`, `limit?` | Feed theo thời gian cho 1 branch |
| `list_branches` | `project?` | Các branch kèm số lượng tag |
| `pin_fact` | `observation_id`, `branch?`, `note?` | Ghim fact vào branch (boost = 1.0) |
| `graduate_fact` | `observation_id` | Promote fact từ branch lên scope project |
| `export_memory` | `branch?`, `all?`, `force?` | Ghi `.tre-mem/` + commit cục bộ (không push) |
| `get_share_status` | `project?` | Số lượng pending / shared / graduated |
| Tool | Input | Output |
| --------------------- | ------------------------------------ | ---------------------------------------------- |
| `get_branch_context` | `query`, `project?`, `branch?`, `k?` | Top-K observations, kèm breakdown rerank |
| `get_branch_timeline` | `branch`, `project?`, `limit?` | Feed theo thời gian cho 1 branch |
| `list_branches` | `project?` | Các branch kèm số lượng tag |
| `pin_fact` | `observation_id`, `branch?`, `note?` | Ghim fact vào branch (boost = 1.0) |
| `graduate_fact` | `observation_id` | Promote fact từ branch lên scope project |
| `unpin_fact` | `observation_id`, `branch?` | Gỡ pin (ghi tombstone nếu đã chia sẻ) |
| `ungraduate_fact` | `observation_id` | Gỡ fact đã graduate (tombstone nếu đã chia sẻ) |
| `export_memory` | `branch?`, `all?`, `force?` | Ghi `.tre-mem/` + commit cục bộ (không push) |
| `get_share_status` | `project?` | Số lượng pending / shared / graduated |

Sau khi assistant pin hoặc graduate một fact, nó có thể gọi **`export_memory`** để
công bố: lệnh này ghi các file `.tre-mem/` và tạo một **commit git cục bộ** — nó
**không bao giờ** push, nên bạn tự review rồi `git push` khi sẵn sàng (tool trả về
đúng câu lệnh cần chạy). Lệnh fail-closed với secret: một lần export bị chặn chỉ báo
_loại_ secret khớp, không bao giờ lộ giá trị.

Khi một fact lỗi thời — feedback PR của leader, bug phát hiện ở QC — assistant gọi
**`unpin_fact`** hoặc **`ungraduate_fact`** để thu hồi. Nếu fact đã được chia sẻ,
lệnh này ghi một **tombstone** vào `.tre-mem/`; ở lần `git pull` kế tiếp mọi clone
của đồng đội tự động bỏ nó. Để _sửa_ một fact, ungraduate cái cũ rồi `graduate_fact`
observation đã sửa.

## Memory xuyên nhiều clone

Nếu bạn clone cùng một repo vào nhiều thư mục (ví dụ `app`, `app-2`, `app-3`) để
Expand Down
2 changes: 1 addition & 1 deletion docs/CROSS-TOOL.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ tre mcp # start by hand; without claude-mem it prints "shared-memory

In the tool, list MCP tools — you should see `get_branch_context`,
`get_branch_timeline`, `list_branches`, `pin_fact`, `graduate_fact`,
`export_memory`, `get_share_status`. Ask:
`unpin_fact`, `ungraduate_fact`, `export_memory`, `get_share_status`. Ask:
_"what has the team pinned on this branch?"_

## Notes
Expand Down
2 changes: 1 addition & 1 deletion docs/DEMO.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Claude Code session in the same repo.

**Expected**: Claude calls the `tre-mem.get_branch_context` MCP tool and
answers in terms of **BMOtpTextView**, not AccountManager. (Check `/mcp` shows
`tre-mem · connected · 7 tools` before recording.)
`tre-mem · connected · 9 tools` before recording.)

Then `git checkout feature/test_tre_mem` in the terminal, ask the same
question again, and watch Claude switch to **AccountManager**.
Expand Down
Loading
Loading