# giter00/dsh-headroom architecture

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

- Interactive diagram: https://gitdiagram.com/giter00/dsh-headroom
- Repository: https://github.com/giter00/dsh-headroom

## Overview

dsh-headroom is a DeepSeek Harness plugin that compresses eligible tool output before it enters session history, while preserving exact originals for retrieval. The graph follows the documented routing and tool workflow; some implementation details are unsampled, so uncertain internal links are omitted.

Main entry points: [`lib/index.js`](https://github.com/giter00/dsh-headroom/blob/main/lib/index.js) (Plugin hook and tools), [`lib/compress.js`](https://github.com/giter00/dsh-headroom/blob/main/lib/compress.js) (Content detection and routing), [`lib/ccr.js`](https://github.com/giter00/dsh-headroom/blob/main/lib/ccr.js) (CCR persistent store), [`lib/kompress.js`](https://github.com/giter00/dsh-headroom/blob/main/lib/kompress.js) (Word scoring pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_integration["Harness integration"]
  node_plugin["Plugin hook and tools<br/>[index.js]"]
end

subgraph group_compression["Compression routing"]
  node_router["Content detection and routing<br/>[compress.js]"]
  node_json["JSON projection<br/>[compress.js]"]
  node_search["Search folding<br/>[compress.js]"]
  node_logs["Log folding<br/>[compress.js]"]
  node_tables["Table folding<br/>[compress.js]"]
  node_text["Long text compression<br/>[compress.js]"]
end

subgraph group_recovery["Recovery and tools"]
  node_ccr[("CCR persistent store<br/>[ccr.js]")]
  node_marker["Retrieval marker<br/>[compress.js]"]
  node_retrieve["headroom_retrieve<br/>[index.js]"]
  node_stats["headroom_stats<br/>[index.js]"]
  node_manual["headroom_compress<br/>[index.js]"]
end

subgraph group_scoring["Text scoring"]
  node_kompress["Word scoring pipeline<br/>[kompress.js]"]
  node_onnx["Optional ONNX scorer<br/>[kompress-onnx.js]"]
end

node_harness(("Harness tool runtime"))
node_history(("Session and model history"))
node_model(("Model"))

node_harness -->|"dispatches hook"| node_plugin
node_plugin -->|"continues execution"| node_harness
node_plugin -->|"routes content"| node_router
node_router -->|"projects JSON"| node_json
node_router -->|"folds search"| node_search
node_router -->|"folds logs"| node_logs
node_router -->|"folds tables"| node_tables
node_router -->|"compresses text"| node_text
node_text -->|"scores words"| node_kompress
node_kompress -.->|"scores with model"| node_onnx
node_plugin -->|"stores originals"| node_ccr
node_plugin -->|"adds marker"| node_marker
node_plugin -->|"returns compressed result"| node_history
node_model -->|"requests original"| node_retrieve
node_retrieve -->|"reads original"| node_ccr
node_plugin -->|"registers tool"| node_stats
node_stats -->|"reads totals"| node_ccr
node_plugin -->|"registers tool"| node_manual
node_manual -->|"compresses text"| node_router

click node_plugin "https://github.com/giter00/dsh-headroom/blob/main/lib/index.js"
click node_router "https://github.com/giter00/dsh-headroom/blob/main/lib/compress.js"
click node_json "https://github.com/giter00/dsh-headroom/blob/main/lib/compress.js"
click node_search "https://github.com/giter00/dsh-headroom/blob/main/lib/compress.js"
click node_logs "https://github.com/giter00/dsh-headroom/blob/main/lib/compress.js"
click node_tables "https://github.com/giter00/dsh-headroom/blob/main/lib/compress.js"
click node_text "https://github.com/giter00/dsh-headroom/blob/main/lib/compress.js"
click node_kompress "https://github.com/giter00/dsh-headroom/blob/main/lib/kompress.js"
click node_onnx "https://github.com/giter00/dsh-headroom/blob/main/lib/kompress-onnx.js"
click node_ccr "https://github.com/giter00/dsh-headroom/blob/main/lib/ccr.js"
click node_marker "https://github.com/giter00/dsh-headroom/blob/main/lib/compress.js"
click node_retrieve "https://github.com/giter00/dsh-headroom/blob/main/lib/index.js"
click node_stats "https://github.com/giter00/dsh-headroom/blob/main/lib/index.js"
click node_manual "https://github.com/giter00/dsh-headroom/blob/main/lib/index.js"

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_plugin toneBlue
class node_router,node_json,node_search,node_logs,node_tables,node_text toneAmber
class node_ccr,node_marker,node_retrieve,node_stats,node_manual toneMint
class node_kompress,node_onnx toneRose
class node_harness,node_history,node_model toneIndigo
```

## Components

### Harness integration

- [Plugin hook and tools](https://github.com/giter00/dsh-headroom/blob/main/lib/index.js): `lib/index.js`

### Compression routing

- [Content detection and routing](https://github.com/giter00/dsh-headroom/blob/main/lib/compress.js): `lib/compress.js`
- [JSON projection](https://github.com/giter00/dsh-headroom/blob/main/lib/compress.js): `lib/compress.js`
- [Search folding](https://github.com/giter00/dsh-headroom/blob/main/lib/compress.js): `lib/compress.js`
- [Log folding](https://github.com/giter00/dsh-headroom/blob/main/lib/compress.js): `lib/compress.js`
- [Table folding](https://github.com/giter00/dsh-headroom/blob/main/lib/compress.js): `lib/compress.js`
- [Long text compression](https://github.com/giter00/dsh-headroom/blob/main/lib/compress.js): `lib/compress.js`

### Recovery and tools

- [CCR persistent store](https://github.com/giter00/dsh-headroom/blob/main/lib/ccr.js): `lib/ccr.js`
- [Retrieval marker](https://github.com/giter00/dsh-headroom/blob/main/lib/compress.js): `lib/compress.js`
- [headroom_retrieve](https://github.com/giter00/dsh-headroom/blob/main/lib/index.js): `lib/index.js`
- [headroom_stats](https://github.com/giter00/dsh-headroom/blob/main/lib/index.js): `lib/index.js`
- [headroom_compress](https://github.com/giter00/dsh-headroom/blob/main/lib/index.js): `lib/index.js`

### Text scoring

- [Word scoring pipeline](https://github.com/giter00/dsh-headroom/blob/main/lib/kompress.js): `lib/kompress.js`
- [Optional ONNX scorer](https://github.com/giter00/dsh-headroom/blob/main/lib/kompress-onnx.js): `lib/kompress-onnx.js`

### Other components

- **Harness tool runtime**
- **Session and model history**
- **Model**

## Connections

- Harness tool runtime → Plugin hook and tools: dispatches hook
- Plugin hook and tools → Harness tool runtime: continues execution
- Plugin hook and tools → Content detection and routing: routes content
- Content detection and routing → JSON projection: projects JSON
- Content detection and routing → Search folding: folds search
- Content detection and routing → Log folding: folds logs
- Content detection and routing → Table folding: folds tables
- Content detection and routing → Long text compression: compresses text
- Long text compression → Word scoring pipeline: scores words
- Word scoring pipeline → Optional ONNX scorer: scores with model
- Plugin hook and tools → CCR persistent store: stores originals
- Plugin hook and tools → Retrieval marker: adds marker
- Plugin hook and tools → Session and model history: returns compressed result
- Model → headroom_retrieve: requests original
- headroom_retrieve → CCR persistent store: reads original
- Plugin hook and tools → headroom_stats: registers tool
- headroom_stats → CCR persistent store: reads totals
- Plugin hook and tools → headroom_compress: registers tool
- headroom_compress → Content detection and routing: compresses text
