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
2 changes: 1 addition & 1 deletion .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"name": "pastdotdev",
"source": "./plugins/past",
"description": "One memory for every teammate and every agent on a project. Your Claude Code sessions go in, and each prompt gets what was decided before, with dated sources.",
"version": "0.4.2",
"version": "0.5.0",
"author": {
"name": "past.dev",
"url": "https://past.dev"
Expand Down
59 changes: 58 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ Claude Code
compaction precompact sends the sittings that closed; the one still open at most once an hour
session end end hands the send to a detached process (flush)
detached idle the waiter: sends once Claude Code's process is gone, or after idleMinutes
detached counts once: the token counts of the sittings already sent
|
~/.past/config.json the connection
~/.past/state.json what was sent and what is open
~/.past/activity/ one file per open session
|
POST /api/v1/recall · POST /api/v1/ingest/batch · GET /api/v1/audiences/{slug}
PUT /api/v1/agent-tokens
```

```
Expand Down Expand Up @@ -217,6 +219,34 @@ Use `updateState` for every change. Keep transcript hashes and pending sessions
last hash in `sittings`, or `null`, and the session's whole hash is written only once every
sitting is in past.dev. The folder's path is never sent: `metadata.project` is the folder's
name. `WAITER_VERSION` went to 7 with it.
17. **What a session cost travels beside it, never in it.** While `modelUsage` is on (the default),
a send carries each sitting's token counts in its item's `agent` object, and a send or a recall
carries three headers: `X-Past-Model`, `X-Past-Model-Billing` and `X-Past-Agent-Memory`.
past.dev works out from them what it saved. None of it is rendered, so no hash moves (rule 10),
and a sitting whose text has not changed is not sent again for its counts.
- The counts are the `usage` Claude Code writes on each of the agent's entries. It writes one
reply on several lines, each repeating the reply's usage, so a reply is counted once, by its
`message.id` (`noteReply`). A reply that only calls a tool counts, and so do the replies in
the session's `subagents` folder (`withSubagents`): a subagent often runs on a smaller model.
A reply belongs to the sitting that was open when it was written (`sittingTokens`).
- The model on a recall is the one that wrote the transcript's last reply, read from the end of
the file (`tailModel`), and before the first reply the one `SessionStart` named, kept on the
session's `pending` entry. The tool and `search` take the most recently written transcript
of their folder. A model nobody can name sends no header.
- How the model is paid for is read from whether a variable or a setting is there, never from
its value: the three `CLAUDE_CODE_USE_*` variables say a cloud provider, an API key or token
variable or an `apiKeyHelper` setting says by the token, and nothing says a subscription.
Claude Code's own memory is on unless `autoMemoryEnabled` is false in its settings (the
person's, then the folder's two, the later winning) or `CLAUDE_CODE_DISABLE_AUTO_MEMORY` is set.
- `counts` mode sends, once, the counts of the sittings already in past.dev whose transcript is
still here: ids and counts through `PUT /api/v1/agent-tokens`, with no content. It never goes
through ingest. A re-send carries the audience in force now, so it would move a sitting sent
under another one, and under another project's key it would be a new paid data point; the
route keeps counts for the data points the project holds and ignores every other id.
`SessionStart` detaches it while `state.counts` holds no `doneAt`. It asks with no items
first, and where the deployment has no such route it tries again a day later.
- `cut` and `status` say what travels beside the text, since that is where a person reads what
leaves. `WAITER_VERSION` went to 8 with it.

## Beside other past.dev plugins

Expand All @@ -243,6 +273,14 @@ cannot read the conversation and can only be recalled from.
every memory drawn from the item, `label` names the session, `metadata` carries
`conversationId`, `sessionId`, `project`, `gitBranch`, `sitting`, and `model` and `effort` where
the transcript names them. A batch takes up to 1,000 items and 16 MB of content.
- An ingest item takes an optional `agent` object beside `metadata`,
`{"tokens": {"<model id>": {"input", "cached_input", "cache_write", "cache_write_1h", "output"}}}`,
where `input` is the input not read from the cache and `cache_write_1h` is the part of
`cache_write` kept for an hour, which the provider prices higher. Ingest and recall read the three `X-Past-*` headers of rule
17. A deployment that knows neither ignores both.
- `PUT /api/v1/agent-tokens` — `items` of `id` and `agent`, up to 1,000, with no content. It answers
how many it kept (`recorded`), how many ids the project does not hold (`unknown`) and how many
it could not read (`ignored`); a call with no items answers zeros.
- `POST /api/v1/recall` — **`identity` is required**. Recall stays off until `/pastdotdev:connect`
sets one. The response is one result per document in rank order; the hooks read each result's
`content` and `occurredAt`, and the tool also its sources' `excerpts` and `metadata.localTime`
Expand All @@ -257,7 +295,16 @@ cannot read the conversation and can only be recalled from.
takes a string where it finds one and otherwise sends nothing. A sitting carries what its last
turn ran on; neither is rendered, so neither changes a hash (rule 10).
- Claude Code gives a hook `session_id`, `transcript_path`, `cwd` and `hook_event_name`, and
takes `hookSpecificOutput.additionalContext` at session start and on a prompt.
takes `hookSpecificOutput.additionalContext` at session start and on a prompt. `SessionStart`
also carries `model`, which Claude Code can leave out (after `/clear`, on a restored session).
- Claude Code writes, on each of the agent's entries, the reply's `message.id` and its
`message.usage`: `input_tokens`, `cache_read_input_tokens`, `cache_creation_input_tokens` and
`output_tokens`, the three kinds of input counted apart, and under `cache_creation` the part of
the cache writes kept for an hour (`ephemeral_1h_input_tokens`). A subagent's thread is a file of the same
shape in `<transcript without .jsonl>/subagents/`. Checked on 2.1.321; the script takes numbers
where it finds them and otherwise counts nothing.
- Claude Code's own memory is the `autoMemoryEnabled` setting, on by default, and
`CLAUDE_CODE_DISABLE_AUTO_MEMORY` turns it off.
- A project API key (`past_sk_…`) names its own project. The plugin never sends a project id.
- `engines` in `plugin.json` names the Claude Code versions the plugin installs on, `>=2.1.76`.
Claude Code 2.1.323 and later install, update and load a plugin from a git marketplace only
Expand All @@ -266,6 +313,9 @@ cannot read the conversation and can only be recalled from.
the release that first needs a newer Claude Code, and prove it both ways: an install inside the
range, and a refusal (`engine_range`) from a git marketplace outside it. A plugin read from a
local folder loads outside its range, so a folder install proves nothing here.
- `VERSION` in the script is the version in `plugin.json` and in the marketplace entry, in every
release, one of words alone too: the `User-Agent` and the recall tool's server name it. 0.4.2
left the script at 0.4.1; 0.5.0 names itself.
- Claude Code starts a plugin's MCP server from the `mcpServers` file its manifest names, expands
`${CLAUDE_PLUGIN_ROOT}` in its arguments, and names its tool `mcp__plugin_pastdotdev_past__past_recall`.

Expand Down Expand Up @@ -303,6 +353,13 @@ throwaway `CLAUDE_CONFIG_DIR` and see `claude mcp list` report `plugin:pastdotde
one over the same transcripts, each in a throwaway home with its own stand-in, and compare what each
mode prints, what each request carries and what `state.json` keeps, byte for byte (rule 10).

For rule 17, run a send in a throwaway home against the stand-in and read the `agent` object of each
item and the three headers; then set `"modelUsage": false` and check that neither is there. For
`counts`, link a few sent transcripts under the throwaway home's `.claude/projects/`, make the
stand-in answer `PUT /api/v1/agent-tokens` with 404, then with 200, and run the mode twice each
time: one empty call and nothing more on 404, one empty call and the items on 200, and nothing at
all on the second run.

For rule 16, run the hooks in a throwaway home with no key, then `connect`, then add a prompt to the
transcript and run the prompt hook and `flush`: one sitting goes, the one after connecting. Do the
same with a second key in place of no key, and check the key each request carries.
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,17 @@ Your prompts and Claude's replies, with the names of the project's folder and it
session's id, the model Claude ran on with its effort level, and the identity you connected with.
The folder's path stays on your machine. Recall
sends queries: one when a session starts, the first 1,000 characters of each prompt, and the
questions Claude asks `past_recall`. Nothing else.
questions Claude asks `past_recall`.

Beside each sitting and each recall go a few facts about the model, which past.dev uses to show
what it saved you on the project's Dashboard: the model's name, the token counts Claude Code
recorded for the sitting (input, cached input, cache writes and output for each model, subagents
included), how you pay for the model (by the token, through a cloud provider or with a
subscription) and whether Claude Code's own memory is on. How you pay is read from whether an API
key or a cloud provider is set, never from a key's value. Once, after the update to 0.5.0, the
plugin also sends the token counts of the sittings it had already sent: their ids and the counts,
with no text. `"modelUsage": false` in `~/.past/config.json` sends none of this. Nothing else
leaves.

What you type is sent with the key it was typed under, and with no other. Nothing typed before you
connect is sent, and what was typed under one project's key never goes to another project: a
Expand Down Expand Up @@ -132,8 +142,9 @@ slug from the console's **Audiences** page. `/pastdotdev:connect --audience proj
`~/.past/config.json` holds the connection and a few switches: `recall` and `ingest` turn either
half off, `idleMinutes` (720) is how long a session stays quiet before it is sent,
`sittingMinutes` (30) is how long a pause starts a new sitting, `sittingKilobytes` (50) how much
prose does, and `deny` lists paths whose sessions are never read. `PAST_API_KEY`, `PAST_IDENTITY`
and `PAST_API_URL` override the file.
prose does, `modelUsage` sends the model's token counts and how it is paid for, and `deny` lists
paths whose sessions are never read. `PAST_API_KEY`, `PAST_IDENTITY` and `PAST_API_URL` override
the file.
Each setting is described in the [plugin's README](plugins/past/README.md#configuration).

For a self-hosted past.dev, pass your deployment's URL as the third argument of `/pastdotdev:connect`. Use
Expand Down
2 changes: 1 addition & 1 deletion plugins/past/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pastdotdev",
"displayName": "past.dev",
"version": "0.4.2",
"version": "0.5.0",
"description": "One memory for every teammate and every agent on a project. Your Claude Code sessions go in, and each prompt gets what was decided before, with dated sources.",
"author": { "name": "past.dev", "url": "https://past.dev" },
"homepage": "https://github.com/pastdotdev/claude-code-plugin",
Expand Down
14 changes: 13 additions & 1 deletion plugins/past/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,16 @@ has just lost.

## What leaves this machine

The prompts, the replies, and the project and branch names. That is all.
The prompts, the replies, the project and branch names, and the model each sitting ran on with
its effort level.

Beside them, while `modelUsage` is on: the token counts Claude Code recorded for each sitting
(input, cached input, cache writes and output for each model, subagents included), how the model
is paid for (by the token, through a cloud provider or with a subscription) and whether Claude
Code's own memory is on. past.dev uses them to show what it saved on the project's Dashboard. How
the model is paid for is read from whether an API key or a cloud provider is set, never from a
key's value. Once, after the update to 0.5.0, the token counts of the sittings already sent go
too: their ids and the counts, with no text. That is all.

Not sent: tool results, file contents, diffs, command output, subagent threads, and anything
the agent injected rather than a person typing it. Strings that look like keys, tokens or
Expand Down Expand Up @@ -118,6 +127,7 @@ something was tried before, and it looks.
"idleMinutes": 720,
"sittingMinutes": 30,
"sittingKilobytes": 50,
"modelUsage": true,
"deny": ["/Users/you/clients/acme"]
}
```
Expand All @@ -132,6 +142,8 @@ something was tried before, and it looks.
- `sittingKilobytes` is how much prose a sitting holds before the next turn starts a new one (50
by default, 10 at least), the cut waiting for the agent's reply. A session keeps the size it was
first sent with.
- `modelUsage: false` stops the token counts, how the model is paid for and whether Claude Code's
own memory is on from being sent. past.dev then has less to work out what it saved from.
- `deny` holds path fragments. A session whose working directory matches one is ignored
completely — nothing is read and nothing is sent.
- `PAST_API_KEY`, `PAST_IDENTITY` and `PAST_API_URL` override the file.
Expand Down
Loading
Loading