activeloopai / activeloopai/hivemind

Weekly recap: include skill auto-pull bytes in Y (v1.1 follow-up)

Đang mở
#127 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
1.6k
Fork
107
Merge trung bình
17 giờ 30 phút
Pull request đã merge (30 ngày)
6

Mô tả

The savings recap in `src/notifications/sources/local-usage.ts` (shipped in `feat/hivemind-savings-recap`) currently computes:

```
Y = memorySearchBytes / 4
Z = 0.7 · Y (per the LoCoMo 1.7× benchmark)
```

`memorySearchBytes` covers two of hivemind's four context-injection channels into a session:
1. ✅ Memory grep results (`Bash(grep ~/.deeplake/memory/summaries/...)` tool_result bytes)
2. ✅ Sessions raw grep results (`Bash(grep ~/.deeplake/memory/sessions/...)` tool_result bytes — same path filter)
3. ❌ **Skill auto-pull content** (this issue) — bytes of `~/.claude/skills//SKILL.md` files that skillify pulled, loaded into context by Claude Code's built-in skill loader at session start.
4. ❌ Excluded by design: SessionStart instructions block (hivemind's "DEEPLAKE MEMORY: ..." preamble — it's hivemind explaining itself, not user past content).

Currently the headline is a conservative lower bound — real savings (including skill contribution) is higher than the displayed number.

## To include skill bytes in Y

One of:

- **(a) Transcript scan**: walk the session JSONL for `attachment.type === "hook_success"` entries whose stdout contains skill-loader system-reminders; count the bytes of the SKILL.md content the loader injected. Most precise (counts only skills Claude actually loaded this session), but requires understanding Claude Code's skill-loader system-reminder format and could break across CC versions.

- **(b) Filesystem scan**: at SessionEnd, `ls ~/.claude/skills/*/SKILL.md` filtered by mtime in the session window AND `author: hivemind` in YAML frontmatter (or equivalent provenance marker), sum their byte sizes. Simpler, but counts skills that were *pulled-but-not-used* this session. Probably suffices for v1.1 — still under-counting compared to "true value delivered," which is fine for the marketing claim.

Recommendation: ship (b) first as a follow-up PR. Add a `skillBytes` field to `UsageRecord`, sum it into Y at render time. Same 1.7× multiplier applies.

## What changes downstream

- `src/notifications/usage-tracker.ts`: add `skillBytes: number` to `UsageRecord`. Backward-compat read for older records.
- `src/hooks/session-end.ts`: in `recordSessionUsage`, scan `~/.claude/skills/` after parsing transcript, populate `skillBytes` on the record.
- `src/notifications/sources/local-usage.ts`: `Y = (memorySearchBytes + skillBytes) / 4`.
- Tests: extend `transcript-parser.test.ts` and `usage-tracker.test.ts` to cover the new field.

## Verification

After this lands, the recap headline should jump (real savings > current under-counted display). Verify by:
1. Add a new skill via `hivemind skillify pull` so a SKILL.md lands under `~/.claude/skills/`.
2. Open a session — note the recap headline value.
3. Open a NEW session — recap should refire with a HIGHER number than before (skill bytes now contribute to Y).

## Related

- PR shipping v1: feat/hivemind-savings-recap on activeloopai/hivemind

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.