activeloopai / activeloopai/hivemind

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

Abierto
#127 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
TypeScript
Estrellas
1.6k
Forks
107
Merge medio
17 h 30 min
PR fusionados (30 d)
6

Descripción

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

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.