Closes #101 (FR-A from the 2026-05-17 German strategy analysis, small-model improvement strategy 5: "History-Zusammenfassung via local"). Phase 5 summarize-on-evict only fires at budget pressure — exactly when the local model is already suffering. Small models benefit from tight context from turn 1, not "after eviction". This commit adds CADENCE-triggered summarization that fires every N appends regardless of budget, folding turns older than `summarize_keep_recent` into ctx.summary via the existing Phase 5 summarize_fn closure. context.lua additions: - New ctx fields: summarize_every_n_turns, summarize_keep_recent (default 4), _turns_since_summarize (counter). - Context:append bumps the counter on every store. - Context:enforce_cadence — the new entry point. Returns the number of turns folded (0 on no-op). Guards: * disabled (cfg unset OR summarize_fn unset) -> 0 * not yet due (_turns_since_summarize < N) -> 0 * Norris-active (Phase 5 R-C4 parity — planner stays on goal) -> 0 * #turns <= keep_recent (nothing to fold) -> 0 * summarize_fn returns nil/empty -> 0 (defer to enforce_budget later) Orphan-tool guard: when the fold slice would end on an assistant-with-tool_calls, peel back the right edge until the next live turn isn't role=tool. Strict chat templates reject tool-without-assistant-anchor (#87 already encountered this). - If ctx.summary grows past max_summary_chars after the fold, compress in a second pass (same shape as enforce_budget's Phase 5 logic). repl.lua wiring: - ctx_opts continues to copy all config.context keys; the new summarize_every_n_turns / summarize_keep_recent fields flow through automatically. - make_summarize_fn is now wired when EITHER summarize_on_evict OR summarize_every_n_turns is set (same closure, different trigger — Phase 5's #51 #issue eviction path uses it on budget; #101 uses it on cadence). - New status_cadence_fold helper: "[aish] proactively summarized N older turns". - ask_ai's existing enforce_budget call site now first fires enforce_cadence, then enforce_budget. Cadence comes first so the token estimate enforce_budget sees is the tighter post-fold one — no spurious eviction of turns we just summarized. - Norris path NOT wired: enforce_cadence is a no-op there via the norris_active guard (consistent with Phase 5 R-C4). 18 inline unit cases for enforce_cadence: - cfg disabled / no summarize_fn / below cadence -> 0 - cadence met -> exact fold count (N - keep) - summary contains folded contents; first/last live turn IDs match - cadence counter resets; second fold fires after another N appends - Norris-active -> suppressed - orphan-tool guard: peels back when last folded = asst+tool_calls - summary compression triggers when over max_summary_chars E2E verified on hossenfelder:8082, summarize_every_n_turns=4 / summarize_keep_recent=2: 5 user turns -> 2 cadence fires: [aish] proactively summarized 2 older turns [aish] proactively summarized 4 older turns :cost detail shows main=5 calls, summarize=2 calls (matches fires). Estimated ctx token count: 180 (vs ~1000 unsummarized). Flag-off path: no status, identical to pre-#101 behavior. Regression: 87/87 safety, 31/31 router_model, repl loads. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
aish
aish — AI-augmented conversational shell.
A single REPL that interleaves shell command execution and language-model conversation, backed by a llama.cpp HTTP broker. Implementation is LuaJIT 2.x with FFI bindings to libcurl, GNU readline, and libc — no C extensions, no build step, one source tree.
Why
Three flows that currently live in three windows fold into one:
- "Run this command and show me the output" — fast feedback loop, no copy-paste between terminal and chat.
- "Explain or write code based on the output we just looked at" — exec output is automatically injected into the model's context.
- "Plan and execute a multi-step task with confirmation gates" — landing in Phase 3 as Chuck Norris autonomous mode.
aish is not a wrapper around bash. It's a first-class interactive environment where the shell is one of several execution channels.
Status
| Component | State |
|---|---|
| Repository skeleton | ✅ in this commit |
| Phase 0 manifest | ✅ docs/PHASE0.md — locked |
| Phase 0 implementation | 🔜 next session |
| Phase 1+ | 📋 enumerated in PHASE0.md §11 |
Every module file currently raises not implemented (Phase 0 pending)
when called. luajit main.lua fails loudly at the first un-implemented
function, never silently.
Quick orientation
| Read this | If you want to know |
|---|---|
docs/PHASE0.md §1–2 |
What aish is and what Phase 0 ships |
docs/PHASE0.md §3 |
Technology decisions (LuaJIT, FFI, readline, libcurl, llama.cpp) |
docs/PHASE0.md §4 |
Directory layout — these file names are stable across all phases |
docs/PHASE0.md §5 |
How input is dispatched (meta / shell / AI) |
docs/PHASE0.md §6 |
Broker contract: /v1/chat/completions, CMD: extraction |
docs/PHASE0.md §10 |
Config schema and resolution order |
docs/PHASE0.md §11 |
Phase sequence (what lands when) |
docs/PHASE0.md §13 |
Open questions, tracked per phase |
CLAUDE.md |
Project conventions for AI-assisted contributors |
Directory layout
aish/
├── main.lua # entry point
├── repl.lua # readline loop, dispatch, prompt
├── broker.lua # llama.cpp HTTP client
├── router.lua # input classifier (meta/shell/AI)
├── executor.lua # command exec + CMD: extraction
├── context.lua # in-memory turn history
├── history.lua # disk persistence (Phase 1+)
├── safety.lua # destructive-op gate (Phase 3+)
├── renderer.lua # output formatting
├── config.lua # default model registry + preferences
├── ffi/
│ ├── curl.lua # libcurl easy interface
│ ├── readline.lua # GNU readline
│ ├── pty.lua # forkpty (Phase 1+)
│ └── libc.lua # chdir, errno, strerror
└── docs/
└── PHASE0.md # locked substrate
Build / runtime dependencies
System packages (Debian / ALARM / Arch names):
luajit(>= 2.0)libcurl4/libcurl-openssl-3runtimelibreadline8runtimelibc6runtime (always present)
No compilation, no luarocks, no make. Just luajit main.lua.
Running
Once Phase 0 ships:
luajit main.lua # uses ~/.config/aish/config.lua
luajit main.lua --config ./config.lua # explicit config path
AISH_CONFIG=/path/to/config.lua luajit main.lua
Config resolution order is documented in docs/PHASE0.md §10.
Configuration
config.lua is a Lua file returning a single table. The committed
config.lua in this repo is both the canonical example and the
development-fallback config (lowest precedence). Copy it to
~/.config/aish/config.lua and edit endpoints to your local llama.cpp
servers, or point AISH_CONFIG at your own.
The default endpoints assume mfritsche's home network:
fast→dirac.fritz.box:8081(Qwen2.5-Coder-7B q4 8k ctx)deep→dirac.fritz.box:8080(Qwen2.5-Coder-7B q4 32k ctx)cloud→hossenfelder.fritz.box:8082(forwards to OpenRouter)
Replace these with your own llama.cpp endpoints if you're not on that LAN.
License
Not yet selected. Default-private until decided.
Project conventions
See CLAUDE.md for contribution conventions, commit style,
and the phase-loop discipline this project follows.