# Project export: Accordion

This document was generated by HackStack to give an AI agent context about a hackathon project. Sections are labeled with their provenance; content marked as truncated was cut to keep this document small.

## Project metadata

- Hackathon: UC Berkeley AI Hackathon 2026
- Tagline: Context management you can trust - Say goodbye to /compact
- Devpost: https://devpost.com/software/accordion-jwarge
- GitHub: https://github.com/a-Fig/Accordion-AI-hackBerkeley
- Video: https://www.youtube.com/embed/T1omrI2VjLA?enablejsapi=1&hl=en_US&rel=0&start=&version=3&wmode=transparent
- Result: winner (Best Compression Model for The Token Company)
- Team: 4 GitHub contributor(s) — Claude Opus 4.8 (24 commits), Tyler Darisme (11 commits), aadityad12 (6 commits), tthy-working (1 commits)

## Devpost submission (written by the team)

### Inspiration

Anyone who has used AI coding agents has seen their context window fills up, and /compact gets called soon after. Just like that your thinking partner has lost 90% of your conversation. Decisions, rules, errors, code, and more gone. We believe this is an inherently naive solution to a problem that deserves real attention.

### What it does

Accordion shows you your entire context window at a glance using a series of blocks in a grid. Each block is colored depending on its type. Those types are user messages, responses, thinking, tool calls and their results. Then, what we call a conductor, reads every block and decides which should be folded, unfolded, or grouped based on custom logic. Folded blocks are replaced with tagged summaries containing a unique code. If the agent needs the original content, it can get it back at any time using our unfold command. Every fold is fully reversible. strategies for conductors range from simple oldest-first folding to harvesting attention from a 500M parameter model to score each blocks relevance to the most recent context. The promise is simple. No blocking calls for compaction, longer smarter coding sessions, and cheaper inference costs. Accomplishments we're proud of Thermocline(one of our conductors) scored 83.3% on SlopCodeBench, 2.5× the 33.3% the same model scored using naive compaction to manage its own context. This is the first conductor to combine attention-based relevance scoring with LLM summaries and block grouping. The result validates that reversible, recall-able folding with intelligent prioritization isn't just theoretically better than naive compaction, it measurably outperforms it on real coding tasks.

### How we built it

Accordion is built around a simple idea: context is a view, not a storage system. We keep the full conversation intact and generate a live view of what gets injected into the model each turn. Folding swaps content for a compact digest; unfolding restores it instantly. The desktop app is built with Tauri, SvelteKit, and TypeScript, while a local WebSocket connection streams live context updates from the running agent to the UI in real time. The Conductor architecture uses a clean synchronous interface — conduct(view) → Command[] — so new folding strategies are a single file to drop in, in any language over the wire or as a direct TypeScript class. One of the biggest technical challenges was preserving tool-call correctness. Since tool calls and their results must remain paired in the provider's message format, Accordion never folds a tool call — only its result — and validates every context view before sending it to the model.

### Challenges we ran into

Control and trust. We wanted automation without sacrificing user control. The final system has a layered trust model: collaborative conductors that users can always override, exclusive conductors with an explicit consent gate showing exactly which controls they claim, and a kill switch (detach) that freezes the current context and hands every control back to you — always, unconditionally. Stable fold handles. When a block is folded, the agent sees a {#code FOLDED} tag in its context — a short handle it can pass back to retrieve the content. That handle has to be stable across sessions, short enough to be noise-free in context, and deterministic so the agent gets the same code every run. We derive it as a stateless hash of the block's durable ID rather than generating it dynamically, so it requires no stored state and survives reconnects cleanly. Automatic folding strategy. Determining what is "important" is harder than it sounds. We ended up building a family of strategies rather than committing to one answer — from a simple oldest-first baseline to an attention-probe-driven scorer (Qwen2.5-0.5B) that identifies which blocks the model is actually attending to.

### What we learned

Treating context manipulation as a UI problem as much as an AI problem unlocked a lot. The hard part wasn't compression — it was giving humans and agents the right level of visibility and control at each layer: what's folded, who did it, and how to get it back. We also learned that the right abstraction is a view over a store, not a store you mutate. Once that clicked, reversibility, attribution, and the agent's ability to reach back for folded content all fell out naturally — no extra infrastructure. Finally: folding strategy is not one thing. The first conductor we built was a clean baseline. The second taught us something the first couldn't. By the time we had nine, each one caught real failure modes the others missed — which is why the architecture is a protocol, not a single algorithm.

### What's next

LLM-generated summaries, computed once and cached — richer prose summaries for individual blocks would make folded content more legible to the agent than raw digests Hierarchical folding — fold the folds, for million-turn sessions: a long session compresses to a handful of headlines you can open to any depth Agent-driven pinning — the agent can already unfold and recall; letting it pin blocks protects them from future automated folding Replay — scrub how the context evolved across a session, so you can see exactly when something got folded, who did it, and what the token budget looked like at each step "Accordion just killed claude" - Tech influencer

## README (from the GitHub repository)


<div align="center">

<picture>
  <source media="(prefers-color-scheme: dark)" srcset="docs/assets/logo-lockup-white.png">
  <img alt="Accordion" src="docs/assets/logo-lockup-black.png" width="440">
</picture>

### /compact is the naive solution, Accordion is the intelligent one.

**See everything your AI agent holds in context — and fold it like an accordion instead.**

<img src="docs/assets/accordion-hero.gif" alt="Accordion — the context map demo: blocks folding and unfolding while the protected tail stays intact" width="820">

<sub>Your whole context window split in 2 sections. The lower section represents your agent's most recent context and is protected against any interference</sub>
</div>

---

Accordion is a [pi](https://github.com/earendil-works/pi) extension that shows you
your agent's entire context window at a glance and lets you manage it manually or with intelligence through a conductor.

<div align="center">

<a href="docs/assets/accordion-demo.mp4"><img src="docs/assets/map-hero.png" alt="Accordion's context Map — a live pi session rendered as a grid of colored blocks" width="860"></a>

</div>

## Why it's different

#### 1. No blocking calls for compaction 
> your context window is automatically managed for you in the background, keeping you below your limit

#### 2. longer more useful sessions
> The relevance of each block is ranked so we only fold bloat, and keep what's important. 

#### 3. Cheaper inference costs
> Accordion keeps your context window lean, with cache optimizations in mind.

Every long-running agent hits the same wall: the context fills up, and something has to
go. Today's answers are dumb and dumber:

- **Compaction** blasts your whole history into one lossy summary — slow, destructive,
  all-or-nothing.
- **Sliding windows** just drop the oldest tokens — the agent simply forgets.

| | Sliding window | `/compact` | skills & memory | 🪗 Accordion |
|---|:---:|:---:|:---:|:---:|
| Keeps old context usable | ❌ | ⚠️ lossy | ⚠️ if retrieved | ✅ |
| **Reversible** to full detail | ❌ | ❌ | ❌ | ✅ |
| No mid-task stall | ✅ | ❌ | ✅ | ✅ |
| Per-section, not all-or-nothing | ❌ | ❌ | ⚠️ | ✅ |
| You can see and steer it | ❌ | ❌ | ❌ | ✅ |
| No extra infra (no vector DB) | ✅ | ✅ | ❌ | ✅ |

## The proof — early, but pointed

Accordion ships with a catalog of interchangeable **Conductors**. The strongest so far,
**[Thermocline](conductors/ws/thermocline/)**, scores each block relevance to the most recent context using the attention from a 500M parameter model as a proxy.

In a test run on **SlopCodeBench** (a long-horizon coding benchmark), Thermocline at a
100k-token budget outperformed naive compaction with the same constrained context budget. Both used deepseekV4Pro.

| Conductor | Context Budget | Score | Checkpoints reached |
|---|:---:|:---:|:---:|
| **Thermocline** | 100k | **83.3%** | 5 / 6 |
| naive compaction | 100k | 33.3% | 2 / 6 |

> ⚠️ **Read this as a signal, not a guarantee.** It's a single hackathon-scale run on a
> subset of the problems — not a published benchmark. Broader, repeatable evaluation is on the roadmap.

## How it works

The **context Map** is the whole window at a glance: one square per block, sized by token
weight (a dice face, 1–6), colored by kind — **user** messages, **assistant** responses,
**thinking**, **tool calls**, and **tool results** each get their own hue. Bright = live;
recessed and hatched = folded.

Three hands share those controls:

- **You** — fold, unfold, pin, and peek by hand. Your overrides always win.
- **The agent** — reaches back to unfold or pin context it needs mid-task, or **recall**
  a folded block as a tool result (like `read_file`) without changing what's standing in
  context.
- **The Conductor** — an automatic strategy that, between turns, folds what's gone cold
  and unfolds what's becoming relevant. Collaborative by default; an *exclusive*
  conductor you approve can take over specific controls, and **detach** is always your
  kill switch.

Every block is **Full**, **Folded** (shown as a short tagged summary), or **Pinned**
(locked open).

<div align="center">
<img src="docs/assets/attention-conductor.png" alt="Attention conductor view — each block tinted by how much the working tail still attends back to it" width="600">
<br><sub>Folded blocks are shown with dull colors </sub>
</div>

Folds nest: cold turns fold into groups, groups into bigger groups, so a session of
thousands of turns stays small enough to fit and complete enough to recover. And the
recent past is always safe — the most recent ~20k tokens are a protected working tail the
agent reasons over at full fidelity (the thick-bordered box below the fold line).

→ Capability matrix, full walkthrough, and the deep spec: **[VISION.md](VISION.md)**

## What works today

- ✅ Desktop app (Tauri + SvelteKit): the Map view, token budget, inspector, protected
  working tail.
- ✅ Live link to a running pi session, with auto-discovery.
- ✅ Opt-in live steering — apply your fold plan to what the agent is shown.
- ✅ Reversible, provider-safe folding with deterministic `{#code FOLDED}` digests the
  agent can ask to unfold.
- ✅ Involvement locks — exclusive conductors, the consent gate, freeze-on-detach, and
  agent `recall`.
- ✅ The Conductor — automatic fold/unfold between turns, based on context.
- ✅ LLM-generated summaries, computed once and cached.
- ✅ Read-only browsing of saved Claude Code transcripts.

Honest about what's **not** there yet: no agent-driven pinning, no hierarchical (nested)
groups, no replay. That's the build ahead.

## Roadmap

- [x] Core fold/unfold engine — reversible, tool-pair safe
- [x] The separate window — desktop app: Map view, budget, inspector
- [x] Live link to pi + auto-discovery, opt-in steering
- [x] Agent-driven unfold + `recall`, involvement locks
- [x] LLM-generated summaries, computed once and cached
- [x] The Conductor — automatic fold/unfold between turns
- [ ] Hierarchical folding for million-turn sessions
- [ ] Agent-driven pin
- [ ] Replay — scrub how context evolved across a session
- [ ] Better conductors — research, develop, and test stronger context strategies
- [ ] Expand accordion beyond pi

## Quick start

### Part 1 — Browser (no Rust, no desktop app)

```bash
pi install npm:@a-fig/accordion
```
restart pi if it is already running, then inside of pi run:                                      
 ```bash
    /accordion                                                                       
 ```
That's it, assuming you have [pi](https://github.com/earendil-works/pi)

---

### Part 2 — Desktop app (Optional - full feature set)

The desktop app adds **multi-session discovery** (switch between running pi sessions from
a sidebar), conductors that require local model resources, and the `/accordion` command
that foregrounds the right session automatically. It requires Node 20+ and Rust.

> **Don't double-register the extension.** Part 1's `pi install npm:@a-fig/accordion`
> already registered the extension (the `/accordion` command, the `unfold`/`recall`
> tools, and the skills all come from the npm package). That same extension is what the
> local `extension/accordion.ts` builds into. **Adding `extension/accordion.ts` to
> `extensions` while the npm package is still installed loads it twice** — a duplicate
> `/accordion` command, duplicate tool registration, and a duplicate context hook. Pick
> **one** of the two paths below; don't do both.

**Prerequisites:** install [Node 20 LTS](https://nodejs.org) and
[Rust via rustup](https://rustup.rs), then follow the one-time platform setup at
**https://v2.tauri.app/start/prerequisites/** (WebView2 + MSVC on Windows, Xcode CLT on
macOS).

#### Path A — Place a built binary (recommended; keeps the npm package)

`/accordion` launches a **pre-built binary** from disk — it does not connect to a dev
server. So all you need is a built `app` binary in one of the locations the extension
scans. If you already ran Part 1, this is the only s

[README truncated for size]

## Detected evidence (automated analysis)

Indexed codebase: 210 recognized source files, 2824 KB.
- CSS (language) — detected in the code
- HTML (language) — detected in the code
- Hugging Face (technology) — detected in the code
- JavaScript (language) — detected in the code
- Python (language) — detected in the code
- PyTorch (technology) — detected in the code
- Rust (language) — detected in the code
- Svelte (technology) — detected in the code
- TypeScript (language) — detected in the code
- Node.js (technology) — claimed on Devpost, not found in the code
- AI coding agent: Claude Code — evidence: config files committed to the repository; commit authorship or trailers
- AI coding agent: Codex — evidence: config files committed to the repository

## Codebase structure (from repository index)

### Files (120 of 277)

```
.gitignore
AGENTS.md
app/.gitignore
app/.vscode/extensions.json
app/.vscode/settings.json
app/package.json
app/README.md
app/src-tauri/.gitignore
app/src-tauri/build.rs
app/src-tauri/capabilities/default.json
app/src-tauri/Cargo.lock
app/src-tauri/Cargo.toml
app/src-tauri/icons/icon.icns
app/src-tauri/src/lib.rs
app/src-tauri/src/main.rs
app/src-tauri/tauri.conf.json
app/src/app.css
app/src/app.html
app/src/lib/conductorDiagnostics.test.ts
app/src/lib/conductorDiagnostics.ts
app/src/lib/engine/__snapshots__/conductor.builtin.test.ts.snap
app/src/lib/engine/__snapshots__/conductor.keel.test.ts.snap
app/src/lib/engine/classify.test.ts
app/src/lib/engine/coldscore.lexical.test.ts
app/src/lib/engine/coldscore.score.test.ts
app/src/lib/engine/conductor.bear2-hybrid.test.ts
app/src/lib/engine/conductor.builtin.test.ts
app/src/lib/engine/conductor.code-skeleton.test.ts
app/src/lib/engine/conductor.coldscore.test.ts
app/src/lib/engine/conductor.compaction-naive.test.ts
app/src/lib/engine/conductor.garbagecollector.test.ts
app/src/lib/engine/conductor.handoff.test.ts
app/src/lib/engine/conductor.keel.bear2.test.ts
app/src/lib/engine/conductor.keel.llm.test.ts
app/src/lib/engine/conductor.keel.test.ts
app/src/lib/engine/conductor.slidingwindow.test.ts
app/src/lib/engine/conductor.test.ts
app/src/lib/engine/digest.test.ts
app/src/lib/engine/digest.ts
app/src/lib/engine/display.sliver.test.ts
app/src/lib/engine/display.test.ts
app/src/lib/engine/display.ts
app/src/lib/engine/foldconsistency.property.test.ts
app/src/lib/engine/parse.test.ts
app/src/lib/engine/parse.ts
app/src/lib/engine/skeletonize.test.ts
app/src/lib/engine/store.foldgate.test.ts
app/src/lib/engine/store.groups.test.ts
app/src/lib/engine/store.host.test.ts
app/src/lib/engine/store.journal.test.ts
app/src/lib/engine/store.locks.test.ts
app/src/lib/engine/store.svelte.ts
app/src/lib/engine/store.test.ts
app/src/lib/engine/tokens.test.ts
app/src/lib/engine/tokens.ts
app/src/lib/engine/types.ts
app/src/lib/live/browserDiscovery.svelte.ts
app/src/lib/live/browserDiscovery.test.ts
app/src/lib/live/claude.ts
app/src/lib/live/claudeDiscovery.svelte.ts
app/src/lib/live/conductor.svelte.ts
app/src/lib/live/conductorClient.svelte.ts
app/src/lib/live/conductorClient.test.ts
app/src/lib/live/conductorDiscovery.svelte.ts
app/src/lib/live/conductorDiscovery.test.ts
app/src/lib/live/conductorMerge.test.ts
app/src/lib/live/conductorMerge.ts
app/src/lib/live/discovery.svelte.ts
app/src/lib/live/foldAlarm.svelte.ts
app/src/lib/live/foldAlarm.test.ts
app/src/lib/live/folding.svelte.ts
app/src/lib/live/ghostState.svelte.ts
app/src/lib/live/ghostState.test.ts
app/src/lib/live/group.crossvalidate.test.ts
app/src/lib/live/liveClient.malformed.test.ts
app/src/lib/live/liveClient.svelte.ts
app/src/lib/live/liveClient.test.ts
app/src/lib/live/mapping.appliedCounts.test.ts
app/src/lib/live/mapping.dropgroup.test.ts
app/src/lib/live/mapping.groups.test.ts
app/src/lib/live/mapping.test.ts
app/src/lib/live/mapping.ts
app/src/lib/live/plan.dropgroup.test.ts
app/src/lib/live/plan.groups.test.ts
app/src/lib/live/plan.test.ts
app/src/lib/live/plan.ts
app/src/lib/live/protocol.ts
app/src/lib/live/registry.ts
app/src/lib/session.svelte.ts
app/src/lib/settings.svelte.ts
app/src/lib/ui/AnimatedNumber.svelte
app/src/lib/ui/conductor/ConductorDashboard.svelte
app/src/lib/ui/EditableNumber.svelte
app/src/lib/ui/Icon.svelte
app/src/lib/ui/live/SessionsSidebar.svelte
app/src/lib/ui/Logo.svelte
app/src/lib/ui/map/ConductorActivity.svelte
app/src/lib/ui/map/ConductorMenu.svelte
app/src/lib/ui/map/ConsentDialog.svelte
app/src/lib/ui/map/ContextMap.svelte
app/src/lib/ui/map/drain.test.ts
app/src/lib/ui/map/drain.ts
app/src/lib/ui/map/Inspector.svelte
app/src/lib/ui/map/MapHeader.svelte
app/src/lib/ui/map/TileCanvas.svelte
app/src/lib/ui/map/tileDraw.test.ts
app/src/lib/ui/map/tileDraw.ts
app/src/lib/ui/SegControl.svelte
app/src/lib/ui/SettingsPanel.svelte
app/src/lib/utils.ts
app/src/routes/+layout.svelte
app/src/routes/+layout.ts
app/src/routes/+page.svelte
app/src/routes/conductor/[sessionId]/+page.svelte
app/src/routes/conductor/+page.svelte
app/static/sample-session.jsonl
app/svelte.config.js
app/tsconfig.json
app/vite.config.js
app/vitest.config.ts
[157 more files omitted for size]
```

### Dependencies

- app/package.json: @fontsource-variable/ibm-plex-sans@^5.2.8, @fontsource/ibm-plex-mono@^5.2.7, @sveltejs/adapter-static@^3.0.6, @sveltejs/kit@^2.9.0, @sveltejs/vite-plugin-svelte@^5.0.0, @tauri-apps/api@^2, @tauri-apps/cli@^2, @tauri-apps/plugin-dialog@^2, @tauri-apps/plugin-fs@^2, @tauri-apps/plugin-opener@^2, @types/node@^26.0.0, svelte@^5.0.0, svelte-check@^4.0.0, typescript@~5.6.2, vite@^6.0.3, vitest@^2.1.9
- app/src-tauri/Cargo.toml: reqwest@0.13, serde@1, serde_json@1, tauri@2, tauri-build@2, tauri-plugin-dialog@2, tauri-plugin-fs@2, tauri-plugin-opener@2, tauri-plugin-single-instance@2
- conductors/attention-folder/package.json: ws@^8.18.0
- conductors/attention-folder/probe/requirements.txt: filelock@==3.29.0, hf-xet@==1.5.1, huggingface_hub@==1.18.0, Jinja2@==3.1.6, networkx@==3.4.2, numpy@==2.2.6, packaging@==26.2, PyYAML@==6.0.3, regex@==2026.5.9, requests, safetensors@==0.8.0, sentencepiece@==0.2.1, sympy@==1.13.1, tokenizers@==0.22.2, torch@==2.5.1+cu121, tqdm@==4.68.2, transformers@==5.11.0
- conductors/recency-folder/package.json: ws@^8.18.0
- conductors/the-conductor-v2/package.json: @huggingface/transformers@^3.8.1, ws@^8.18.0
- conductors/the-conductor/package.json: @huggingface/transformers@^3.8.1, ws@^8.18.0
- conductors/thermocline/package.json: ws@^8.18.0
- conductors/tiered-relevance/package.json: @huggingface/transformers@^3.8.1, ws@^8.18.0
- extension/package.json: @earendil-works/pi-agent-core@*, @earendil-works/pi-ai@*, @earendil-works/pi-coding-agent@*, esbuild@^0.25.0, jiti@^2.7.0, typebox@*, ws@^8.18.0

### Recent commits (newest first)

- Merge pull request #52 from a-Fig/devmain
- Merge pull request #72 from a-Fig/fix/ws-auth-hardening
- fix(extension): gate Tauri Vite origin
- fix(extension): harden loopback WS and completion relay
- Merge pull request #81 from a-Fig/chore/simplify-rip-birthfold-recall-remote
- docs: fix stale birth-fold/recall references (review follow-up)
- simplify: finish conductor protocol lockstep (review follow-up)
- Update CLAUDE.md with Pi extension hooks
- Merge pull request #80 from a-Fig/docs/document-pi-hooks
- simplify: remove remote binding (loopback-only browser-served)
- docs: document pi extension hooks
- simplify: remove conductor recall command (re-file as issue)
- simplify: remove birth folding (re-file as issue)
- Merge pull request #74 from a-Fig/claude/accordion-improvements-mgqlub
- fix(app): harden transcript loading and the unauthenticated WS pump
- Merge pull request #71 from a-Fig/fix/extension-server-hardening
- Merge pull request #70 from a-Fig/fix/handoff-hardening
- Merge pull request #69 from a-Fig/fix/browser-discovery-resilience
- Merge pull request #68 from a-Fig/fix/birthfold-wire-truth
- Merge pull request #67 from a-Fig/docs/promotion-drift

## Key source files (fetched from GitHub, selected and truncated for size)

### AGENTS.md

```markdown
Read the entirety of @CLAUDE.md

## Worktree convention

Before making any changes to the code, **always open a dedicated worktree** — never edit in the main checkout.

1. **Create a worktree off the latest `devmain`**, placed under `.pi/worktrees/` (already gitignored):
   ```bash
   git fetch origin
   git worktree add .pi/worktrees/<short-descriptive> -b <branch> origin/devmain
   cd .pi/worktrees/<short-descriptive>
   ```
2. **Do all work in the worktree** — edits, `npm install` (deps are per-worktree), verification (`npm run check`, `npm run test`, `node smoke.mjs`, `npm pack --dry-run` as applicable), commits, and the PR to `devmain`.
3. **Delete the worktree and its folder once the branch is merged** into `devmain` (or promoted to `main`):
   ```bash
   cd <main checkout>
   git worktree remove .pi/worktrees/<short-descriptive>
   git branch -d <branch>   # safe once merged; use -D only if the branch was abandoned
   ```
4. Notes:
   - The main checkout stays on `main` (the stable, registered-binary surface). Never branch from or PR into `main` directly — see CLAUDE.md → *Branching & PR workflow*.
   - Only one worktree may run the UI server on port 1420 at a time (`npm run dev` / `tauri dev`). Other concurrent worktrees should rely on `npm run check` / `npm run test` / `node smoke.mjs`, which claim no port.
   - If the branch is abandoned without merging, still `git worktree remove` it so `.pi/worktrees/` doesn't accumulate stale trees.

```

### CONTRIBUTING.md

```markdown
# Contributing to Accordion

This guide gets a new contributor from a fresh clone to a running dev build and a
clean quality gate. For *what* the product is, read [VISION.md](VISION.md); for *how
the code is organized and the conventions to follow*, read [CLAUDE.md](CLAUDE.md) — it
is the authoritative guide to working in this codebase.

The active surface is the desktop app in **`app/`** (Tauri 2 + SvelteKit), the pi
extension in **`extension/`** (the live link), and the conductor strategies in
**`conductors/`**.

---

## 1. Prerequisites

| Tool | Version | Notes |
|---|---|---|
| **Node.js** | 20 LTS (≥18) | ships with `npm`, which this repo uses |
| **Rust** | stable, via [rustup](https://rustup.rs) | builds the Tauri native layer (`app/src-tauri`) |
| **pi** | latest | only needed to work on the **live link** (optional) |

Tauri also needs platform system libraries. Install them once — the official list is the
source of truth: **https://v2.tauri.app/start/prerequisites/**. In short:

- **Windows** — [WebView2 runtime](https://developer.microsoft.com/microsoft-edge/webview2/)
  (preinstalled on Win 11) and the **Microsoft C++ Build Tools** (the "Desktop development
  with C++" workload), which provide the MSVC linker Rust needs.
- **macOS** — Xcode Command Line Tools: `xcode-select --install`.
- **Linux (Debian/Ubuntu)** — `webkit2gtk-4.1`, `build-essential`, `curl`, `wget`, `file`,
  `libxdo-dev`, `libssl-dev`, `libayatana-appindicator3-dev`, `librsvg2-dev` (package names
  vary by distro — follow the Tauri prerequisites page).

Verify your toolchain:

```bash
node -v      # v20.x (or ≥18)
cargo -V     # any recent stable
```

---

## 2. Clone & install

```bash
git clone https://github.com/a-Fig/accordion.git
cd accordion

# the desktop app
cd app && npm install

# the pi extension (only if you'll touch the live link)
cd ../extension && npm install
```

The first `npm run tauri dev` / `cargo` invocation also compiles the Rust crates, which
can take a few minutes on a cold checkout. That's normal.

---

## 3. Run it

From `app/`:

```bash
npm run tauri dev   # the native desktop window — REQUIRED for live session discovery
```

`tauri dev` starts the Vite dev server and the native shell together (hot-reload on save).
Its browser-obtainable `http://localhost:1420` Origin is not trusted by the pi extension in
shipped/default mode. For live-link testing only, start the **pi process** with
`ACCORDION_ALLOW_TAURI_DEV_ORIGIN=1`; production Tauri custom-protocol origins need no flag.

For pure UI iteration you can skip the native shell:

```bash
npm run dev         # browser only → http://localhost:1420
```

The browser build can't read the `~/.accordion/` registry, so live session discovery is
disabled there — it falls back to a manual-port Connect box and the bundled demo. Use the
**desktop** app for anything involving live sessions.

> Both `npm run dev` and `npm run tauri dev` want **port 1420** — run only one at a time.

---

## 4. Quality gat
[truncated — 4774 more characters]
```

### app/package.json

```
{
  "name": "app",
  "version": "0.1.0",
  "description": "",
  "type": "module",
  "scripts": {
    "dev": "vite dev",
    "build": "vite build",
    "preview": "vite preview",
    "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
    "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
    "test": "vitest run",
    "tauri": "tauri"
  },
  "license": "MIT",
  "dependencies": {
    "@fontsource-variable/ibm-plex-sans": "^5.2.8",
    "@fontsource/ibm-plex-mono": "^5.2.7",
    "@tauri-apps/api": "^2",
    "@tauri-apps/plugin-dialog": "^2",
    "@tauri-apps/plugin-fs": "^2",
    "@tauri-apps/plugin-opener": "^2"
  },
  "devDependencies": {
    "@sveltejs/adapter-static": "^3.0.6",
    "@sveltejs/kit": "^2.9.0",
    "@sveltejs/vite-plugin-svelte": "^5.0.0",
    "@tauri-apps/cli": "^2",
    "@types/node": "^26.0.0",
    "svelte": "^5.0.0",
    "svelte-check": "^4.0.0",
    "typescript": "~5.6.2",
    "vite": "^6.0.3",
    "vitest": "^2.1.9"
  }
}

```

### extension/package.json

```
{
  "name": "@a-fig/accordion",
  "version": "0.1.2",
  "type": "module",
  "description": "Accordion live link — a pi extension that streams context to the Accordion GUI and applies the fold plan the GUI returns.",
  "keywords": ["pi-package"],
  "scripts": {
    "build:app": "npm --prefix ../app run build",
    "build:extension": "node ./build-extension.mjs",
    "build:client": "node ./build-client.mjs",
    "build": "npm run build:app && npm run build:client && npm run build:extension",
    "prepack": "npm run build && npm run smoke",
    "smoke": "node smoke.mjs && node smoke-config.mjs"
  },
  "pi": {
    "extensions": ["./accordion.js"]
  },
  "files": [
    "accordion.js",
    "dist",
    "skills",
    "README.md"
  ],
  "dependencies": {
    "ws": "^8.18.0"
  },
  "peerDependencies": {
    "@earendil-works/pi-coding-agent": "*",
    "@earendil-works/pi-agent-core": "*",
    "@earendil-works/pi-ai": "*",
    "typebox": "*"
  },
  "devDependencies": {
    "esbuild": "^0.25.0",
    "jiti": "^2.7.0"
  }
}

```

### conductors/thermocline/package.json

```
{
  "name": "accordion-conductor-thermocline",
  "version": "0.1.0",
  "private": true,
  "type": "module",
  "description": "Thermocline conductor for Accordion — layers block significance and manages multi-tier context folding.",
  "scripts": {
    "start": "node thermocline.mjs",
    "test": "node --test"
  },
  "dependencies": {
    "ws": "^8.18.0"
  }
}

```

### conductors/recency-folder/package.json

```
{
  "name": "accordion-conductor-recency-folder",
  "version": "0.1.0",
  "private": true,
  "type": "module",
  "description": "Reference conductor for Accordion — folds the oldest non-protected tool_results until the context is under budget.",
  "main": "recency-folder.js",
  "scripts": {
    "start": "node recency-folder.js"
  },
  "dependencies": {
    "ws": "^8.18.0"
  }
}

```

### conductors/attention-folder/package.json

```
{
  "name": "accordion-conductor-attention-folder",
  "version": "0.1.0",
  "private": true,
  "type": "module",
  "description": "Attention-based PERIODIC conductor for Accordion — a Qwen2.5-0.5B probe scores structural gravity; folds the least-attended blocks in epochs to keep the window in a 70–90% band while preserving the inference prompt cache.",
  "main": "attention-folder.mjs",
  "scripts": {
    "start": "node attention-folder.mjs",
    "test": "node --test"
  },
  "dependencies": {
    "ws": "^8.18.0"
  }
}

```

### conductors/the-conductor-v2/package.json

```
{
  "name": "accordion-conductor-the-conductor-v2",
  "version": "0.1.0",
  "private": true,
  "type": "module",
  "description": "V2 of the_conductor's context strategy as an Accordion external (WebSocket) conductor: recoverable custom digests, host-native summaries, structured telemetry, self-calibrating fold-target band, graduated Full/Trim/Digest/Group fold levels, three-stage relevance, and risk-aware unfold floors.",
  "main": "the-conductor.ts",
  "scripts": {
    "start": "node the-conductor.ts",
    "test": "node --test"
  },
  "engines": {
    "node": ">=22.18"
  },
  "dependencies": {
    "ws": "^8.18.0"
  },
  "optionalDependencies": {
    "@huggingface/transformers": "^3.8.1"
  }
}

```

### conductors/tiered-relevance/package.json

```
{
  "name": "accordion-conductor-tiered-relevance",
  "version": "0.1.0",
  "private": true,
  "type": "module",
  "description": "Relevance-driven level-of-detail conductor for Accordion — every block sits at the fidelity tier (Full/Trim/Digest/Group) its unified relevance earns; a 60–90% hysteresis band makes fold/unfold one stable re-tiering. Embeddings default to Ollama embeddinggemma; LLM digests use Ollama/Gemini/Anthropic with deterministic fallback.",
  "main": "tiered-relevance.mjs",
  "scripts": {
    "start": "node tiered-relevance.mjs",
    "test": "node --test"
  },
  "dependencies": {
    "ws": "^8.18.0"
  },
  "optionalDependencies": {
    "@huggingface/transformers": "^3.8.1"
  }
}

```

### conductors/the-conductor/package.json

```
{
  "name": "accordion-conductor-the-conductor",
  "version": "0.1.0",
  "private": true,
  "type": "module",
  "description": "Faithful port of the_conductor's context strategy as an Accordion external (WebSocket) conductor: self-calibrating fold-target band, graduated Full/Trim/Digest/Group fold levels, three-stage relevance (keyword -> embeddings -> cross-encoder rerank), risk-aware unfold floors, and conductor pins. Strategy vendored from the_conductor/src/conductor.ts; only the I/O ends are re-expressed against the conductor contract.",
  "main": "the-conductor.ts",
  "scripts": {
    "start": "node the-conductor.ts",
    "test": "node --test"
  },
  "engines": {
    "node": ">=22.18"
  },
  "dependencies": {
    "ws": "^8.18.0"
  },
  "optionalDependencies": {
    "@huggingface/transformers": "^3.8.1"
  }
}

```

[188 more indexed source files omitted to keep this export small. The full file list is in the Codebase structure section above.]