hffmnnj.prompt-cache
v0.1.0
Published
Append-only OpenCode context snapshots with content-free reset diagnostics
Readme
OpenCode prompt-cache projection
hffmnnj.prompt-cache retains trusted Goals, Memory and Clef context snapshots in
their original positions and appends changed snapshots. The latest revision from
each producer supersedes older revisions. This preserves an append-only request
prefix between genuine history changes; it does not guarantee provider cache hits.
Install
Add exactly one projection entry after the plugins that produce transient context:
{
"plugins": [
{ "package": "[email protected]" }
]
}Replace an existing local opencode-cache-protect/prompt-cache entry rather than
loading both. The runtime ID remains opencode.prompt-cache, so existing plugin
storage and snapshot keys remain compatible. The package does not register or
replace the separate Cache Protect safety guards.
The plugin uses OpenCode's context hook, not a provider transport or unsupported cache field. Its small message-constructor graph is bundled; the plugin API and the constructor graph's Effect runtime are explicit pinned dependencies, so the package does not rely on a source checkout's dependency hoisting. No inference, retries or keepalives are introduced.
Diagnostics
The existing opencode.prompt-cache log includes resetReasons: an empty array
when retained snapshots were not reset, otherwise directly observed causes:
model_changed: the retained state's model identity differs.system_changed: the system-part hash differs.history_shortened: canonical history is shorter than the retained prefix.history_changed: a retained canonical-history hash differs.owners_removed: a producer was removed while the other prefix checks passed.producers_inactive: no trusted active producer remains.
Several observed changes can be reported together. Reset events also carry fixed
six-reason resetCounts, cumulative for this plugin instance and restarted on
reload. These counts are not provider cache misses. Logs contain existing session
and model IDs, counts and fixed reasons, never prompt text, payload hashes or
credentials. The diagnostics do not change system parts, messages, tool schemas,
snapshot storage or projection decisions.
Model/provider changes normally select isolated storage keys. A previously unseen
key can therefore initialize without a reset; model_changed describes a mismatch
within retained state, not every model switch or cold provider request.
Limits and local development
Snapshot retention can grow context faster and cause earlier compaction. Genuine instruction, model and history changes still invalidate the retained prefix; provider expiry and billing behavior are outside this plugin's visibility. Malformed or unsupported layouts retain the existing fail-open behavior.
From a source checkout, run bun install --frozen-lockfile and
bun run build:prompt-cache at the repository root. The maintained build updates
both the local artifact and this package's bundle and revisioned entrypoint.
Check the actual loaded V2 plugin catalog after activation; a standalone import is
only a packaging smoke test.
