opencode-live-compact 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@
5
5
  ## How it works
6
6
 
7
7
  1. OpenCode's idle hook signals successful completion with no pending inputs. The plugin checks the completed tool states and protects active tool rounds while allowing completed history to compact even when background dev servers or watchers are running. The active turn and the latest three completed tool rounds stay intact by default.
8
- 2. The planner considers completed history after the last visible checkpoint. Eligible content includes older assistant prose, stock reads, file listings, searches, and verified successful foreground shell output. Each cut must contain at least 1,000 estimated tokens of source text selected for shortening by default; a span can combine several smaller entries. Preserved reasoning, tool-call arguments, and unchanged results do not count toward that minimum. Ordinary cuts contain at most 32,000 estimated source tokens. Every changed entry must reduce both estimated tokens and serialized size, including its checkpoint and recall reference; saving fewer than 1,000 tokens is allowed. It compares batches of up to three completed spans or individual results. Each span stays within completed work and user/checkpoint boundaries. Shortened entries share an archive reference, with their replacement text bounded by an 8,000-code-point budget per span.
8
+ 2. The planner considers completed history after the last visible checkpoint. Eligible content includes older assistant prose, stock reads, file listings, searches, and verified successful foreground shell output. A completed foreground command that exited with an error can also qualify when the plugin recognizes its entire flat Node TAP or plain TypeScript report and preserves every failure. Each cut must contain at least 1,000 estimated tokens of source text selected for shortening by default; a span can combine several smaller entries. Preserved reasoning, tool-call arguments, and unchanged results do not count toward that minimum. Ordinary cuts contain at most 32,000 estimated source tokens. Every changed entry must reduce both estimated tokens and serialized size, including its checkpoint and recall reference; saving fewer than 1,000 tokens is allowed. It compares batches of up to three completed spans or individual results. Each span stays within completed work and user/checkpoint boundaries. Shortened entries share an archive reference, with their replacement text bounded by an 8,000-code-point budget per span.
9
9
  3. The planner ranks useful batches by estimated tokens saved, discounted by the retained suffix after the earliest cut: `saved / (1 + suffix / saved)`. This favors larger reductions and shorter suffixes without rejecting a useful cut because of cache prices. It is a selection heuristic, not a cost estimate. Originals are preserved together in one durable transaction before queuing a local compaction. The compaction hook rechecks the queued item, original contents, and prefix, then constructs the replacement window by copying only changed messages. The host persists it and uses it to size later requests. [OpenCode compaction hook](https://opencode.ai/docs/build/plugins/server#hooks)
10
10
  4. OpenCode replays the saved window on the same provider and model. On a model switch, the host falls back to the original history. Stock compaction stays enabled, and later successful turns can create new replacement windows.
11
11
 
@@ -15,9 +15,9 @@ Span cuts preserve OpenCode's mixed messages in place. Reasoning, tool calls, th
15
15
 
16
16
  OpenCode records each local replacement as a compaction event and stores the full active window for that event. The benchmark separates these events from stock compaction and records their start-to-end durations. These intervals do not directly measure user-visible waiting: planning can occur before an event, while application overlaps it. A full-context replay is local maintenance, not another cut or a native summary. Compatibility was verified with stock compaction defaults.
17
17
 
18
- User messages, system instructions, provider-bound reasoning, recent assistant responses, diagnostics, and active or interrupted work stay intact. Cuts use a local byte-based token estimate. Actual prompt-cache reuse and billing depend on the provider and workload.
18
+ User messages, system instructions, provider-bound reasoning, recent assistant responses, exact failure details, and active or interrupted work stay intact. Cuts use a local byte-based token estimate. Actual prompt-cache reuse and billing depend on the provider and workload.
19
19
 
20
- An otherwise eligible tool result above 32,000 estimated tokens can use a small recovery pointer instead of an excerpt. Its exact header, truncation notice, and observed status remain. This exception never applies to assistant prose. The full original must fit the archive's 512 KiB per-record limit and be stored successfully; otherwise it stays visible.
20
+ An otherwise eligible tool result above 32,000 estimated tokens can use a small recovery pointer instead of an excerpt. Its exact header, truncation notice, and observed status remain. Assistant prose and known command failures are ineligible for pointer-only replacement. A recognized failure keeps its full output whenever the diagnostic card cannot fit. The full original must fit the archive's 512 KiB per-record limit and be stored successfully; otherwise it stays visible.
21
21
 
22
22
  ## Configuration
23
23
 
@@ -59,4 +59,4 @@ Without diagnostics, planning reason changes are logged at INFO and storage/repl
59
59
 
60
60
  Recall failures include a reason and an instruction to re-read the source: `missing` (including foreign-session references), `expired` (recently evicted retired record), `unreadable` (the owned payload or integrity check is invalid), or `storage-unavailable`. Content-free expiry records survive restart, are capped at `archiveMaxRecords`, and are removed on session deletion. Older evictions eventually become `missing`. Active records remain protected from retention and capacity eviction.
61
61
 
62
- Carried round metadata contains only fields used by eligibility checks. Reads retain path and offset; shell/search inputs use empty string sentinels because eligibility checks only their string type. These are internal validation evidence, not executable or model-visible tool arguments. Original calls and recoverable text stay unchanged. Only relevant outcome metadata is retained. Legacy full-input evidence remains readable, and hashes, active-tool protection, pairing, and prefix checks still apply on replay.
62
+ Carried round metadata contains only fields used by eligibility checks. Reads retain the path and offset. Recognized test and compiler commands retain a canonical signature for revalidating the report. Other shell commands and searches retain only an empty string where eligibility requires a string. These are internal validation evidence, not executable or model-visible tool arguments. Original calls and recoverable text stay unchanged. Only relevant outcome metadata is retained. Legacy full-input evidence remains readable, and hashes, active-tool protection, pairing, and prefix checks still apply on replay.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-live-compact",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "Deterministic incremental context compaction for OpenCode V2",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -30,6 +30,10 @@
30
30
  "./server": {
31
31
  "types": "./dist/index.d.ts",
32
32
  "import": "./dist/index.js"
33
+ },
34
+ "./tui": {
35
+ "types": "./dist/tui.d.ts",
36
+ "import": "./dist/tui.js"
33
37
  }
34
38
  },
35
39
  "files": [
@@ -39,7 +43,8 @@
39
43
  "README.zh-CN.md",
40
44
  "docs/architecture.md",
41
45
  "docs/assets/benchmarks-en.svg",
42
- "docs/assets/benchmarks-zh-CN.svg"
46
+ "docs/assets/benchmarks-zh-CN.svg",
47
+ "docs/assets/terminal-demo.gif"
43
48
  ],
44
49
  "scripts": {
45
50
  "build": "tsc -p tsconfig.build.json",
@@ -57,7 +62,11 @@
57
62
  },
58
63
  "devDependencies": {
59
64
  "@opencode/client": "2.2.6",
65
+ "@opencode/theme": "2.2.6",
66
+ "@opentui/core": "0.8.1",
67
+ "@opentui/solid": "0.8.1",
60
68
  "@types/node": "22.20.5",
69
+ "solid-js": "1.9.17",
61
70
  "typescript": "5.9.3"
62
71
  },
63
72
  "publishConfig": {