# bowenliang123/dsh-context architecture

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

- Interactive diagram: https://gitdiagram.com/bowenliang123/dsh-context
- Repository: https://github.com/bowenliang123/dsh-context

## Overview

dsh-context is a DeepSeek Harness plugin for inspecting and managing an agent’s context across sessions. Its principal workflow folds session events into context projections, delivers them to the client, and presents composition, request history, and assembled content in the Context view or /context modal. A separate dashboard summarizes usage and session activity; preferences control presentation. The README documents additional event, file-activity, timing, and agent-network views. Connections reflect shown registrations, imports, and documented behavior; several UI internals are unsampled, so their wiring is only included where supported.

Main entry points: [`src/client/components/contextView.tsx`](https://github.com/bowenliang123/dsh-context/blob/main/src/client/components/contextView.tsx) (Context tab), [`src/client/index.ts`](https://github.com/bowenliang123/dsh-context/blob/main/src/client/index.ts) (Plugin registration), [`src/host/timeline.ts`](https://github.com/bowenliang123/dsh-context/blob/main/src/host/timeline.ts) (Context timeline), [`src/host/index.ts`](https://github.com/bowenliang123/dsh-context/blob/main/src/host/index.ts) (Host registration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Host projections"]
  node_fold["Event fold<br/>[fold.ts]"]
  node_timeline["Context timeline<br/>[timeline.ts]"]
  node_host_entry["Host registration<br/>[index.ts]"]
  node_activity["Activity projection<br/>[activity.ts]"]
  node_backfill["Activity backfill<br/>[backfill.ts]"]
end

subgraph group_client["Context views"]
  node_plugin["Plugin registration<br/>[index.ts]"]
  node_services["Harness services<br/>[services.ts]"]
  node_context_view["Context tab<br/>[contextView.tsx]"]
  node_browser["Context browser<br/>[browser.tsx]"]
  node_trend["Request trend<br/>[trendChart.tsx]"]
  node_composition["Current composition"]
  node_agent_network["Agent network<br/>[agentGraph.tsx]"]
  node_file_activity["File activity<br/>[fileActivity.ts]"]
  node_modal["Context command modal<br/>[contextModal.tsx]"]
  node_settings["Preferences<br/>[settings.ts]"]
end

subgraph group_overview["Dashboard"]
  node_history["Dashboard data<br/>[historyPage.ts]"]
  node_overview["Context dashboard<br/>[overviewPanel.tsx]"]
end

subgraph group_shared["Shared data"]
  node_wire["Wire contracts<br/>[types.ts]"]
  node_cost["Cost estimates<br/>[cost.ts]"]
  node_providers["Provider mapping<br/>[providers.ts]"]
end

node_user(("Harness user"))
node_harness{{"Harness runtime"}}

node_user -->|"opens sessions"| node_harness
node_harness -->|"loads plugin"| node_host_entry
node_host_entry -->|"registers projection"| node_timeline
node_timeline -->|"applies events"| node_fold
node_host_entry -->|"registers projection"| node_activity
node_host_entry -->|"starts backfill"| node_backfill
node_timeline -->|"builds view"| node_wire
node_harness -->|"loads client"| node_plugin
node_plugin -->|"registers view"| node_context_view
node_plugin -->|"uses harness boundary"| node_services
node_timeline -->|"streams projection"| node_context_view
node_context_view -->|"renders browser"| node_browser
node_context_view -.->|"shows request trend"| node_trend
node_context_view -->|"shows composition"| node_composition
node_context_view -.->|"shows agent network"| node_agent_network
node_context_view -->|"derives activity"| node_file_activity
node_plugin -->|"registers command surface"| node_modal
node_plugin -->|"watches history"| node_history
node_history -.->|"feeds dashboard"| node_overview
node_plugin -->|"registers dashboard"| node_overview
node_plugin -->|"creates preferences"| node_settings
node_context_view -.->|"estimates spend"| node_cost
node_cost -->|"resolves providers"| node_providers

click node_plugin "https://github.com/bowenliang123/dsh-context/blob/main/src/client/index.ts"
click node_fold "https://github.com/bowenliang123/dsh-context/blob/main/src/host/fold.ts"
click node_timeline "https://github.com/bowenliang123/dsh-context/blob/main/src/host/timeline.ts"
click node_host_entry "https://github.com/bowenliang123/dsh-context/blob/main/src/host/index.ts"
click node_activity "https://github.com/bowenliang123/dsh-context/blob/main/src/host/activity.ts"
click node_backfill "https://github.com/bowenliang123/dsh-context/blob/main/src/host/backfill.ts"
click node_wire "https://github.com/bowenliang123/dsh-context/blob/main/src/shared/types.ts"
click node_services "https://github.com/bowenliang123/dsh-context/blob/main/src/client/services.ts"
click node_context_view "https://github.com/bowenliang123/dsh-context/blob/main/src/client/components/contextView.tsx"
click node_browser "https://github.com/bowenliang123/dsh-context/blob/main/src/client/components/browser.tsx"
click node_trend "https://github.com/bowenliang123/dsh-context/blob/main/src/client/components/trendChart.tsx"
click node_composition "https://github.com/bowenliang123/dsh-context/blob/main/src/client/components/currentComposition.tsx"
click node_agent_network "https://github.com/bowenliang123/dsh-context/blob/main/src/client/components/agentGraph.tsx"
click node_file_activity "https://github.com/bowenliang123/dsh-context/blob/main/src/client/fileActivity.ts"
click node_modal "https://github.com/bowenliang123/dsh-context/blob/main/src/client/components/contextModal.tsx"
click node_history "https://github.com/bowenliang123/dsh-context/blob/main/src/client/historyPage.ts"
click node_overview "https://github.com/bowenliang123/dsh-context/blob/main/src/client/components/overviewPanel.tsx"
click node_settings "https://github.com/bowenliang123/dsh-context/blob/main/src/client/settings.ts"
click node_cost "https://github.com/bowenliang123/dsh-context/blob/main/src/client/cost.ts"
click node_providers "https://github.com/bowenliang123/dsh-context/blob/main/src/shared/providers.ts"

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_fold,node_timeline,node_host_entry,node_activity,node_backfill,node_user toneBlue
class node_plugin,node_services,node_context_view,node_browser,node_trend,node_composition,node_agent_network,node_file_activity,node_modal,node_settings toneAmber
class node_history,node_overview toneMint
class node_wire,node_cost,node_providers toneRose
class node_harness toneIndigo
```

## Components

### Host projections

- [Event fold](https://github.com/bowenliang123/dsh-context/blob/main/src/host/fold.ts): `src/host/fold.ts`
- [Context timeline](https://github.com/bowenliang123/dsh-context/blob/main/src/host/timeline.ts): `src/host/timeline.ts`
- [Host registration](https://github.com/bowenliang123/dsh-context/blob/main/src/host/index.ts): `src/host/index.ts`
- [Activity projection](https://github.com/bowenliang123/dsh-context/blob/main/src/host/activity.ts): `src/host/activity.ts`
- [Activity backfill](https://github.com/bowenliang123/dsh-context/blob/main/src/host/backfill.ts): `src/host/backfill.ts`

### Context views

- [Plugin registration](https://github.com/bowenliang123/dsh-context/blob/main/src/client/index.ts): `src/client/index.ts`
- [Harness services](https://github.com/bowenliang123/dsh-context/blob/main/src/client/services.ts): `src/client/services.ts`
- [Context tab](https://github.com/bowenliang123/dsh-context/blob/main/src/client/components/contextView.tsx): `src/client/components/contextView.tsx`
- [Context browser](https://github.com/bowenliang123/dsh-context/blob/main/src/client/components/browser.tsx): `src/client/components/browser.tsx`
- [Request trend](https://github.com/bowenliang123/dsh-context/blob/main/src/client/components/trendChart.tsx): `src/client/components/trendChart.tsx`
- [Current composition](https://github.com/bowenliang123/dsh-context/blob/main/src/client/components/currentComposition.tsx): `src/client/components/currentComposition.tsx`
- [Agent network](https://github.com/bowenliang123/dsh-context/blob/main/src/client/components/agentGraph.tsx): `src/client/components/agentGraph.tsx`
- [File activity](https://github.com/bowenliang123/dsh-context/blob/main/src/client/fileActivity.ts): `src/client/fileActivity.ts`
- [Context command modal](https://github.com/bowenliang123/dsh-context/blob/main/src/client/components/contextModal.tsx): `src/client/components/contextModal.tsx`
- [Preferences](https://github.com/bowenliang123/dsh-context/blob/main/src/client/settings.ts): `src/client/settings.ts`

### Dashboard

- [Dashboard data](https://github.com/bowenliang123/dsh-context/blob/main/src/client/historyPage.ts): `src/client/historyPage.ts`
- [Context dashboard](https://github.com/bowenliang123/dsh-context/blob/main/src/client/components/overviewPanel.tsx): `src/client/components/overviewPanel.tsx`

### Shared data

- [Wire contracts](https://github.com/bowenliang123/dsh-context/blob/main/src/shared/types.ts): `src/shared/types.ts`
- [Cost estimates](https://github.com/bowenliang123/dsh-context/blob/main/src/client/cost.ts): `src/client/cost.ts`
- [Provider mapping](https://github.com/bowenliang123/dsh-context/blob/main/src/shared/providers.ts): `src/shared/providers.ts`

### Other components

- **Harness user**
- **Harness runtime**

## Connections

- Harness user → Harness runtime: opens sessions (evidence: `README.md`)
- Harness runtime → Host registration: loads plugin (evidence: `src/host/index.ts`)
- Host registration → Context timeline: registers projection (evidence: `src/host/index.ts`)
- Context timeline → Event fold: applies events (evidence: `src/host/timeline.ts`)
- Host registration → Activity projection: registers projection (evidence: `src/host/index.ts`)
- Host registration → Activity backfill: starts backfill (evidence: `src/host/index.ts`)
- Context timeline → Wire contracts: builds view (evidence: `src/shared/types.ts`)
- Harness runtime → Plugin registration: loads client (evidence: `src/client/index.ts`)
- Plugin registration → Context tab: registers view (evidence: `src/client/index.ts`)
- Plugin registration → Harness services: uses harness boundary (evidence: `src/client/index.ts`)
- Context timeline → Context tab: streams projection
- Context tab → Context browser: renders browser (evidence: `src/client/components/contextView.tsx`)
- Context tab → Request trend: shows request trend (evidence: `README.md`)
- Context tab → Current composition: shows composition (evidence: `src/client/components/contextView.tsx`)
- Context tab → Agent network: shows agent network (evidence: `README.md`)
- Context tab → File activity: derives activity (evidence: `src/client/components/contextView.tsx`)
- Plugin registration → Context command modal: registers command surface (evidence: `src/client/index.ts`)
- Plugin registration → Dashboard data: watches history (evidence: `src/client/index.ts`)
- Dashboard data → Context dashboard: feeds dashboard (evidence: `README.md`)
- Plugin registration → Context dashboard: registers dashboard (evidence: `src/client/index.ts`)
- Plugin registration → Preferences: creates preferences (evidence: `src/client/index.ts`)
- Context tab → Cost estimates: estimates spend (evidence: `README.md`)
- Cost estimates → Provider mapping: resolves providers (evidence: `src/client/cost.ts`)
