Summarize the previous session into a work_log note on startup #1

Merged
kerryhatcher merged 4 commits from session-worklog-hook into main 2026-08-11 14:55:32 +00:00
Owner

Summary

  • Adds the plugin's first hook: on SessionStart (startup only, async), peachmem worklog digests the previous session's transcript, summarizes it via claude -p (Haiku by default), and saves the result as a work_log-tagged note with a classification tag and a session:<id> idempotency key. The one-sentence description is injected back into the new session as context.
  • Adds [worklog] config table (model, digest size, timeout, cost ceiling) with backwards-compatible defaults for existing config.toml files.
  • Adds publishing to a self-hosted Forgejo Cargo registry (.cargo/config.toml, README docs) so the crate installs via cargo install --registry kerryhatcher peachmem.
  • Bumps plugin/crate version to 0.2.0.

Test plan

  • cargo test — unit tests cover config defaults/back-compat and worklog digest reduction
  • cargo clippy
  • cargo publish --registry kerryhatcher --dry-run --allow-dirty
## Summary - Adds the plugin's first hook: on `SessionStart` (startup only, async), `peachmem worklog` digests the previous session's transcript, summarizes it via `claude -p` (Haiku by default), and saves the result as a `work_log`-tagged note with a classification tag and a `session:<id>` idempotency key. The one-sentence description is injected back into the new session as context. - Adds `[worklog]` config table (model, digest size, timeout, cost ceiling) with backwards-compatible defaults for existing `config.toml` files. - Adds publishing to a self-hosted Forgejo Cargo registry (`.cargo/config.toml`, README docs) so the crate installs via `cargo install --registry kerryhatcher peachmem`. - Bumps plugin/crate version to 0.2.0. ## Test plan - [x] `cargo test` — unit tests cover config defaults/back-compat and worklog digest reduction - [x] `cargo clippy` - [x] `cargo publish --registry kerryhatcher --dry-run --allow-dirty`
Adds the plugin's first hook. On SessionStart (startup only, async so it
never delays a session), `peachmem worklog` finds the previous session's
transcript, reduces it to a digest, asks Haiku for a one-sentence
description, a classification, and a short markdown worklog, and saves the
result as a note tagged work_log plus the classification. The headline is
returned as additionalContext, so the new session opens knowing what the
last one did.

Transcripts are megabytes of mostly tool output — 3.7 MB for one session
here — so the file is streamed and reduced to the parts that carry intent:
user prompts verbatim, assistant prose, and tool calls as name plus one
identifying argument. Tool results, thinking blocks, subagent traffic and
injected scaffolding are dropped. On a real transcript that is a 45x
reduction with every user prompt preserved.

The summarizer shells out to `claude -p`, which reuses existing Claude Code
credentials so there is no API key to configure. Three of its flags are
load-bearing rather than preference, and a test pins them: --safe-mode (or
the child runs this hook and recurses), --no-session-persistence (or the
child's own transcript becomes the next session's "previous session"), and
--tools "" (a summarizer has no business touching the filesystem). The
child is spawned with kill_on_drop and killed and reaped explicitly on
timeout, and the pipe drain carries its own deadline, since a grandchild
holding the write end can block long past the child's exit.

Every failure path is soft — missing CLI, Postgres down, bad payload, model
error — because a worklog is never worth disrupting a session over. The
session tag doubles as an idempotency key, so re-running is a no-op.

Sizing is measured, not guessed: the digest is billed roughly twice because
structured output costs a second tool-call turn, so an 84k-char digest cost
$0.104 and blew the budget. The 40k default lands near $0.055.

Bumps the plugin and crate to 0.2.0 so the installed plugin cache, which is
a plain file copy pinned to an older commit, actually refreshes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Adds the registry definition, publish metadata, and release docs so the crate
can be installed with `cargo install --registry kerryhatcher peachmem`.

`.cargo/config.toml` is checked in because it holds no secrets and because
`publish = ["kerryhatcher"]` refers to that registry name — without it cargo
cannot resolve the registry at all. The token stays per-machine in
~/.cargo/credentials.toml. That same `publish` key makes a bare `cargo
publish` an error rather than an attempt to push this to crates.io.

The registry config is excluded from the tarball: cargo reads a package-root
.cargo/config.toml when building an extracted crate, and a consumer's build
should not inherit our registry.

Verified with `cargo publish --dry-run --allow-dirty`, which resolved the
index and reached the upload step before aborting. The verification build
from the tarball also confirms sqlx::migrate!("./migrations") still resolves
once packaged, since the migrations ship with the crate.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Now that peachmem publishes to the Forgejo cargo registry, plugin
manifests and the session-start hook no longer need to build from
source in the plugin checkout — they just invoke `peachmem` directly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kerryhatcher/peachmem!1
No description provided.