# m-newhauser/gliner25-compaction architecture

> Architecture diagram of the GitHub repository m-newhauser/gliner25-compaction, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/m-newhauser/gliner25-compaction
- Repository: https://github.com/m-newhauser/gliner25-compaction

## Overview

GLiNER2.5 Local Context prunes completed coding-agent tool interactions locally, retaining exact evidence rather than generating summaries or transmitting transcripts to an external model. Claude Code invokes pruning during native compaction, while OpenCode offers explicit `/gliner-prune` actions against provider-bound context. Both paths lead to transcript normalization, model-based retention analysis, safety validation, and evidence-preserving rendering. The OpenCode bridge and sidecar wiring is represented from sampled source; the README documents both harnesses, but Pi is explicitly planned and not implemented.

Main entry points: [`src/gliner25_context_compaction/worker.py`](https://github.com/m-newhauser/gliner25-compaction/blob/main/src/gliner25_context_compaction/worker.py) (Worker entry), [`src/gliner25_context_compaction/compact.py`](https://github.com/m-newhauser/gliner25-compaction/blob/main/src/gliner25_context_compaction/compact.py) (Retention and rendering), [`integrations/opencode/src/server.ts`](https://github.com/m-newhauser/gliner25-compaction/blob/main/integrations/opencode/src/server.ts) (Plugin server), [`src/gliner25_context_compaction/analyzer.py`](https://github.com/m-newhauser/gliner25-compaction/blob/main/src/gliner25_context_compaction/analyzer.py) (GLiNER analyzer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_harnesses["Agent harnesses"]
  node_claude_hook["Compaction hook"]
  node_root_hook["Compaction hook"]
end

subgraph group_opencode["OpenCode integration"]
  node_tui["Prune command<br/>[tui.ts]"]
  node_server["Plugin server<br/>[server.ts]"]
  node_bridge["Local bridge<br/>[bridge.ts]"]
  node_adapter["Transcript adapter<br/>[adapter.ts]"]
  node_sidecar_client["Sidecar client<br/>[sidecar-client.ts]"]
  node_protocol["Wire protocol<br/>[protocol.ts]"]
end

subgraph group_engine["Pruning engine"]
  node_sidecar["Sidecar service<br/>[sidecar.py]"]
  node_worker["Worker entry<br/>[worker.py]"]
  node_claude_codec["Transcript codec<br/>[claude.py]"]
  node_transcript["Interaction collection<br/>[transcript.py]"]
  node_compact["Retention and rendering<br/>[compact.py]"]
  node_validation["Result validation<br/>[validation.py]"]
end

subgraph group_inference["Local inference"]
  node_analyzer["GLiNER analyzer<br/>[analyzer.py]"]
  node_schema["Label schema<br/>[schema.py]"]
end

node_claude_actor(("Claude Code"))
node_opencode_actor(("OpenCode user"))
node_model[("GLiNER2.5 checkpoint")]

node_claude_actor -->|"compacts via"| node_claude_hook
node_claude_actor -.->|"compacts via"| node_root_hook
node_claude_hook -->|"runs worker"| node_worker
node_root_hook -->|"runs worker"| node_worker
node_opencode_actor -->|"selects command"| node_tui
node_tui -->|"sends request"| node_bridge
node_server -->|"starts handler"| node_bridge
node_server -->|"normalizes transcript"| node_adapter
node_server -->|"requests analysis"| node_sidecar_client
node_sidecar_client -->|"spawns and exchanges"| node_sidecar
node_sidecar -->|"dispatches request"| node_worker
node_worker -->|"converts messages"| node_claude_codec
node_worker -->|"compacts transcript"| node_compact
node_worker -->|"validates result"| node_validation
node_claude_codec -->|"supplies messages"| node_compact
node_compact -->|"collects interactions"| node_transcript
node_compact -->|"analyzes interactions"| node_analyzer
node_analyzer -->|"uses labels"| node_schema
node_analyzer -->|"runs local inference"| node_model

click node_claude_hook "https://github.com/m-newhauser/gliner25-compaction/blob/main/integrations/claude-code/hooks/gliner25-pruning.ts"
click node_root_hook "https://github.com/m-newhauser/gliner25-compaction/blob/main/hooks/gliner25-compaction.ts"
click node_tui "https://github.com/m-newhauser/gliner25-compaction/blob/main/integrations/opencode/src/tui.ts"
click node_server "https://github.com/m-newhauser/gliner25-compaction/blob/main/integrations/opencode/src/server.ts"
click node_bridge "https://github.com/m-newhauser/gliner25-compaction/blob/main/integrations/opencode/src/bridge.ts"
click node_adapter "https://github.com/m-newhauser/gliner25-compaction/blob/main/integrations/opencode/src/opencode/adapter.ts"
click node_sidecar_client "https://github.com/m-newhauser/gliner25-compaction/blob/main/integrations/opencode/src/sidecar-client.ts"
click node_protocol "https://github.com/m-newhauser/gliner25-compaction/blob/main/integrations/opencode/src/protocol.ts"
click node_sidecar "https://github.com/m-newhauser/gliner25-compaction/blob/main/src/gliner25_context_compaction/sidecar.py"
click node_worker "https://github.com/m-newhauser/gliner25-compaction/blob/main/src/gliner25_context_compaction/worker.py"
click node_claude_codec "https://github.com/m-newhauser/gliner25-compaction/blob/main/src/gliner25_context_compaction/claude.py"
click node_transcript "https://github.com/m-newhauser/gliner25-compaction/blob/main/src/gliner25_context_compaction/transcript.py"
click node_compact "https://github.com/m-newhauser/gliner25-compaction/blob/main/src/gliner25_context_compaction/compact.py"
click node_validation "https://github.com/m-newhauser/gliner25-compaction/blob/main/src/gliner25_context_compaction/validation.py"
click node_analyzer "https://github.com/m-newhauser/gliner25-compaction/blob/main/src/gliner25_context_compaction/analyzer.py"
click node_schema "https://github.com/m-newhauser/gliner25-compaction/blob/main/src/gliner25_context_compaction/schema.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_claude_hook,node_root_hook,node_opencode_actor toneBlue
class node_tui,node_server,node_bridge,node_adapter,node_sidecar_client,node_protocol,node_model toneAmber
class node_sidecar,node_worker,node_claude_codec,node_transcript,node_compact,node_validation toneMint
class node_analyzer,node_schema toneRose
class node_claude_actor toneIndigo
```

## Components

### Agent harnesses

- [Compaction hook](https://github.com/m-newhauser/gliner25-compaction/blob/main/integrations/claude-code/hooks/gliner25-pruning.ts): `integrations/claude-code/hooks/gliner25-pruning.ts`
- [Compaction hook](https://github.com/m-newhauser/gliner25-compaction/blob/main/hooks/gliner25-compaction.ts): `hooks/gliner25-compaction.ts`

### OpenCode integration

- [Prune command](https://github.com/m-newhauser/gliner25-compaction/blob/main/integrations/opencode/src/tui.ts): `integrations/opencode/src/tui.ts`
- [Plugin server](https://github.com/m-newhauser/gliner25-compaction/blob/main/integrations/opencode/src/server.ts): `integrations/opencode/src/server.ts`
- [Local bridge](https://github.com/m-newhauser/gliner25-compaction/blob/main/integrations/opencode/src/bridge.ts): `integrations/opencode/src/bridge.ts`
- [Transcript adapter](https://github.com/m-newhauser/gliner25-compaction/blob/main/integrations/opencode/src/opencode/adapter.ts): `integrations/opencode/src/opencode/adapter.ts`
- [Sidecar client](https://github.com/m-newhauser/gliner25-compaction/blob/main/integrations/opencode/src/sidecar-client.ts): `integrations/opencode/src/sidecar-client.ts`
- [Wire protocol](https://github.com/m-newhauser/gliner25-compaction/blob/main/integrations/opencode/src/protocol.ts): `integrations/opencode/src/protocol.ts`

### Pruning engine

- [Sidecar service](https://github.com/m-newhauser/gliner25-compaction/blob/main/src/gliner25_context_compaction/sidecar.py): `src/gliner25_context_compaction/sidecar.py`
- [Worker entry](https://github.com/m-newhauser/gliner25-compaction/blob/main/src/gliner25_context_compaction/worker.py): `src/gliner25_context_compaction/worker.py`
- [Transcript codec](https://github.com/m-newhauser/gliner25-compaction/blob/main/src/gliner25_context_compaction/claude.py): `src/gliner25_context_compaction/claude.py`
- [Interaction collection](https://github.com/m-newhauser/gliner25-compaction/blob/main/src/gliner25_context_compaction/transcript.py): `src/gliner25_context_compaction/transcript.py`
- [Retention and rendering](https://github.com/m-newhauser/gliner25-compaction/blob/main/src/gliner25_context_compaction/compact.py): `src/gliner25_context_compaction/compact.py`
- [Result validation](https://github.com/m-newhauser/gliner25-compaction/blob/main/src/gliner25_context_compaction/validation.py): `src/gliner25_context_compaction/validation.py`

### Local inference

- [GLiNER analyzer](https://github.com/m-newhauser/gliner25-compaction/blob/main/src/gliner25_context_compaction/analyzer.py): `src/gliner25_context_compaction/analyzer.py`
- [Label schema](https://github.com/m-newhauser/gliner25-compaction/blob/main/src/gliner25_context_compaction/schema.py): `src/gliner25_context_compaction/schema.py`

### Other components

- **Claude Code**
- **OpenCode user**
- **GLiNER2.5 checkpoint**

## Connections

- Claude Code → Compaction hook: compacts via
- Claude Code → Compaction hook: compacts via
- Compaction hook → Worker entry: runs worker
- Compaction hook → Worker entry: runs worker
- OpenCode user → Prune command: selects command
- Prune command → Local bridge: sends request
- Plugin server → Local bridge: starts handler
- Plugin server → Transcript adapter: normalizes transcript
- Plugin server → Sidecar client: requests analysis
- Sidecar client → Sidecar service: spawns and exchanges
- Sidecar service → Worker entry: dispatches request
- Worker entry → Transcript codec: converts messages
- Worker entry → Retention and rendering: compacts transcript
- Worker entry → Result validation: validates result
- Transcript codec → Retention and rendering: supplies messages
- Retention and rendering → Interaction collection: collects interactions
- Retention and rendering → GLiNER analyzer: analyzes interactions
- GLiNER analyzer → Label schema: uses labels
- GLiNER analyzer → GLiNER2.5 checkpoint: runs local inference
