Skip to content

Commit 8cb9093

Browse files
Merge pull request #10 from claudioemmanuel/feat/context-engine
feat(context): aggressive token-engine — adaptive intensity, redundancy cache, summarize fallback
2 parents f4dc431 + a0c2454 commit 8cb9093

25 files changed

Lines changed: 7124 additions & 10 deletions

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ jobs:
1515
cp target/release/squeez "$HOME/.claude/squeez/bin/squeez"
1616
- name: Run benchmarks
1717
run: bash bench/run.sh
18+
- name: Run context-engine benchmarks
19+
run: bash bench/run_context.sh

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@
44
.omc/
55
docs/
66
.worktrees/
7+
8+
# Bench reports (regenerated on every run)
9+
bench/report.md
10+
bench/report_context.md
11+

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,40 @@ bypass = docker exec, psql, ssh
6666
# Session memory
6767
compact_threshold_tokens = 160000 # warn at 80% of context budget
6868
memory_retention_days = 30 # how long to keep session summaries
69+
70+
# Context engine (PR1)
71+
adaptive_intensity = true # auto-tighten compression as budget fills
72+
context_cache_enabled = true # persist cross-call state in sessions/context.json
73+
redundancy_cache_enabled = true # collapse identical recent outputs to a reference line
74+
summarize_threshold_lines = 500 # raw lines above this trigger summary fallback
6975
```
7076

77+
### Context engine
78+
79+
When `adaptive_intensity = true` (default), squeez compresses every bash call
80+
at maximum aggression — limits ×0.3 across the board (Ultra mode):
81+
82+
- `max_lines` × 0.3 (floor 20)
83+
- `dedup_min` × 0.5 (floor 2)
84+
- `git_diff_max_lines`, `docker_logs_max_lines`, `find_max_results` × 0.3
85+
- `summarize_threshold_lines` × 0.3 (floor 50)
86+
87+
Set `adaptive_intensity = false` to fall back to **Lite** (no scaling, raw
88+
defaults). The active level is shown in the bash header:
89+
`# squeez [git] 841→323 tokens (-62%) 55ms [adaptive: Ultra]`.
90+
91+
The `Lite` and `Full` enum variants remain for forward compatibility but are
92+
not selected automatically — they exist so future versions can introduce
93+
softer modes without breaking the public API.
94+
95+
When the same compressed output appears within the last 8 calls (length-equality
96+
guarded), squeez replaces it with a single reference line:
97+
`[squeez: identical to <hash> at bash#<n> — re-run with --no-squeez]`.
98+
99+
When raw output exceeds `summarize_threshold_lines`, squeez emits a dense
100+
≤40-line summary (top errors, top files, test summary, last 20 lines verbatim)
101+
instead of running the per-handler truncation pipeline.
102+
71103
## How it works
72104

73105
### Claude Code & Copilot CLI
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
On branch develop
2+
Your branch is up to date with origin/develop.
3+
4+
Changes not staged for commit:
5+
(use git add to update what will be committed)
6+
(use git restore to discard changes in working directory)
7+
modified: src/main.rs
8+
modified: src/lib.rs
9+
modified: src/config.rs
10+
modified: src/commands/wrap.rs
11+
modified: tests/test_intensity.rs
12+
modified: tests/test_redundancy.rs
13+
modified: tests/test_summarize.rs
14+
modified: tests/test_context_cache.rs
15+
modified: bench/run.sh
16+
modified: README.md
17+
18+
no changes added to commit (use git add and/or git commit -a)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
On branch develop
2+
Your branch is up to date with origin/develop.
3+
4+
Changes not staged for commit:
5+
(use git add to update what will be committed)
6+
(use git restore to discard changes in working directory)
7+
modified: src/main.rs
8+
modified: src/lib.rs
9+
modified: src/config.rs
10+
modified: src/commands/wrap.rs
11+
modified: tests/test_intensity.rs
12+
modified: tests/test_redundancy.rs
13+
modified: tests/test_summarize.rs
14+
modified: tests/test_context_cache.rs
15+
modified: bench/run.sh
16+
modified: README.md
17+
18+
no changes added to commit (use git add and/or git commit -a)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
On branch develop
2+
Your branch is up to date with origin/develop.
3+
4+
Changes not staged for commit:
5+
(use git add to update what will be committed)
6+
(use git restore to discard changes in working directory)
7+
modified: src/main.rs
8+
modified: src/lib.rs
9+
modified: src/config.rs
10+
modified: src/commands/wrap.rs
11+
modified: tests/test_intensity.rs
12+
modified: tests/test_redundancy.rs
13+
modified: tests/test_summarize.rs
14+
modified: tests/test_context_cache.rs
15+
modified: bench/run.sh
16+
modified: README.md
17+
18+
no changes added to commit (use git add and/or git commit -a)

0 commit comments

Comments
 (0)