Fix the loop stalling after compaction, add an external registry

The compaction bug, which is the important one:

beta.2 taught the pruner to drop any assistant part whose reasoning item it had
removed. That was right about the 400 and wrong about everything else. On a
reasoning model every tool call carries a provider itemId, so past the threshold
the model could no longer see what it had already run, and re-ran the same tools
until maxSteps ended the turn. Reproduced at 12 model calls for a job needing 4,
with nothing but the user message reaching the wire.

The dependency is not the part, it is the itemId. A part carrying one is
serialised as `{ type: 'item_reference', id }`, a pointer to an item stored
provider-side that depends on its reasoning item. Without the itemId the same
content goes out inline and carries no dependency at all. Verified against the
provider's own serialiser: `text` with an itemId becomes item_reference, the
identical part without one becomes output_text.

So `dropOrphanedItems` becomes `detachOrphanedItems`: strip the itemId, keep the
content. Compaction may shorten the history; it must not blank it. The new test
asserts behaviour rather than shape — the loop must end because the model chose
to, and every call after the first must still carry the earlier exchange. A shape
assertion passed the whole time the model was losing its memory.

Registry, via `/registry [list|search|add|remove|installed]`:

Skills and plugins are treated differently on purpose. A skill is prompt text, so
installing one puts a stranger's words into the system prompt of every future
session in this project; the install shows the body first and the origin is
recorded, so /skills always says where an instruction came from. A plugin is a
JSON manifest of deny rules, evaluated by compiled code identical for every
install. Loading TypeScript from a URL is declined outright: a plugin that can
block tool calls could otherwise lie about blocking them.

Validated before anything is written: https only (file: and data: rejected), name
matched against ^[a-z0-9][a-z0-9-]*$ so it cannot escape its directory, size
caps on index and body, every regex compiled, pattern length capped since it runs
on every tool call, and the body's own name checked against the index. Installed
skills rank below your own, so an install can never shadow a skill you wrote.

Interface:
- Context is a percentage of the compaction threshold, amber from two thirds and
  red at 90. A turn about to lose history now says so beforehand.
- Aligned command menu and registry tables; /skills and /plugins name origins.

538 tests, up from 488. The registry is tested against a real local HTTP server,
and the guard is proven to refuse a .env write end to end rather than assumed to.
This commit is contained in:
Muhammad Zakir Ramadhan committed 2026-09-03 03:07:56 +07:00
1 parent 8b1895de98
commit 84c60f2022
26 files changed
+1929 -149

No files matched your search

+10 -4
View File
@@ -88,6 +88,10 @@ the agent puts a question on screen with options.
message, so a search across forty files does not fill the main context. Its progress
streams to a panel.
**Extensible from the prompt.** `/registry` browses external skills and plugins and installs
them with one confirmation. A skill is shown in full before its text joins your system prompt;
a plugin is a manifest of refusal rules, never code.
**Remembers between sessions.** Decisions, working commands, and traps go into per-project
memory that is injected at the start of every future session.
@@ -109,6 +113,7 @@ core ones and a disabled set reaches neither the wire nor the prompt.
| [Agents and thinking](docs/agents.md) | variants, thinking levels, read-only modes |
| [Skills](docs/skills.md) | the bundled skills and writing your own |
| [Plugins](docs/plugins.md) | the plugin interface and the builtins |
| [Registry](docs/registry.md) | installing external skills and plugins |
| [Memory and state](docs/memory.md) | memory, task lists, sessions, compaction |
| [MCP](docs/mcp.md) | connecting Model Context Protocol servers |
| [Headless mode](docs/headless.md) | `-p`, JSON events, exit codes, CI recipes |
@@ -123,8 +128,9 @@ Type `/` and a menu appears, narrowing as you type.
```
/help /agent [name] /think [level] /provider /models /model <id>
/skills /plugins /init /context /todos /notes /memory
/tools /compact /cost /sessions /resume <id> /save /clear /exit
/skills /plugins /registry [search|add|remove] /init /context
/todos /notes /memory /tools /compact /cost
/sessions /resume <id> /save /clear /exit
```
`esc` dismisses a panel, interrupts a running turn, and clears the queue. `ctrl-c` kills the
@@ -136,11 +142,11 @@ workspace path. Up and down recall earlier prompts.
Working: the agent loop, tool approvals, subagents, skills, plugins, per-project memory,
session persistence, MCP, markdown rendering, headless mode, five-platform builds, streaming
reasoning display, the mid-turn prompt queue, gateable tool sets, read-only git tools, batch
reads, `@file` completion, and interruptible commands.
reads, `@file` completion, interruptible commands, and the external registry.
Next up is in [TODO.md](TODO.md); the longer view and what has been declined are in
[ROADMAP.md](ROADMAP.md). The short version of what is missing: a summary of what compaction
discarded, `web_fetch`, and a cheaper model for subagent searches.
discarded, `web_fetch`, a spend ceiling, and a cheaper model for subagent searches.
## License