# mearihaka/dsh-longing architecture

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

- Interactive diagram: https://gitdiagram.com/mearihaka/dsh-longing
- Repository: https://github.com/mearihaka/dsh-longing

## Overview

dsh-longing is a platform-independent DSH plugin that maintains a changing character state and renders it as model-facing context. The main flow is incoming chat activity, state updates and decay, then channel-specific prompt injection; the panel and diary provide additional ways to inspect or manage the experience. The README documents several capabilities whose internal wiring is not visible in the excerpts, so those relationships are cited to the README rather than presented as inspected call paths.

Main entry points: [`src/index.js`](https://github.com/mearihaka/dsh-longing/blob/main/src/index.js) (Plugin Orchestrator), [`src/prompt.js`](https://github.com/mearihaka/dsh-longing/blob/main/src/prompt.js) (Prompt Rendering), [`src/curve.js`](https://github.com/mearihaka/dsh-longing/blob/main/src/curve.js) (State Dynamics), [`src/events.js`](https://github.com/mearihaka/dsh-longing/blob/main/src/events.js) (Event Effects)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Plugin Runtime"]
  node_plugin["Plugin Orchestrator<br/>[index.js]"]
  node_config["Configuration Schema<br/>[config.js]"]
end

subgraph group_state["State Engine"]
  node_statefiles[("Persistent State<br/>[index.js]")]
  node_curve["State Dynamics<br/>[curve.js]"]
  node_events["Event Effects<br/>[events.js]"]
  node_autoevent["Event Detection<br/>[auto-event.js]"]
  node_anchor["Activity Tracking<br/>[anchor.js]"]
end

subgraph group_experience["Character Experience"]
  node_mood["Scene and Mood<br/>[mood.js]"]
  node_unlock["Progressive Unlocks<br/>[unlock.js]"]
  node_behavior["Reply Behavior<br/>[behavior.js]"]
  node_prompt["Prompt Rendering<br/>[prompt.js]"]
  node_diary["Mood Diary<br/>[diary.js]"]
  node_reflect["Diary Reflection<br/>[reflect.js]"]
  node_recall["Event Recall<br/>[recall.js]"]
  node_proactive["Proactive Gates<br/>[proactive.js]"]
  node_curio["Curiosity Search<br/>[curio.js]"]
end

subgraph group_interfaces["User Interfaces"]
  node_panel["Web Panel<br/>[index.html]"]
end

subgraph group_integrations["External Integrations"]
  node_channel["Channel Plugin"]
  node_search["Web Search"]
  node_comfy["ComfyUI"]
end

node_user(("Chat User"))
node_dsh(("DSH Host"))

node_dsh -->|"loads plugin"| node_plugin
node_user -->|"sends messages"| node_channel
node_channel -->|"reports activity"| node_plugin
node_plugin -->|"uses settings"| node_config
node_plugin -->|"reads and writes"| node_statefiles
node_plugin -.->|"updates state"| node_curve
node_plugin -.->|"detects events"| node_autoevent
node_plugin -.->|"applies events"| node_events
node_plugin -.->|"tracks activity"| node_anchor
node_plugin -->|"maintains diary"| node_diary
node_plugin -->|"requests reflection"| node_reflect
node_plugin -->|"searches topics"| node_curio
node_plugin -->|"builds injections"| node_prompt
node_plugin -->|"provides context"| node_channel
node_curve -->|"supplies calculations"| node_prompt
node_events -->|"changes shared state"| node_curve
node_prompt -->|"renders scene"| node_mood
node_prompt -->|"renders boundaries"| node_unlock
node_prompt -.->|"adds reply guidance"| node_behavior
node_prompt -.->|"includes remembered events"| node_recall
node_plugin -.->|"checks initiative"| node_proactive
node_plugin -->|"serves panel"| node_panel
node_panel -->|"requests status"| node_plugin
node_curio -->|"queries topics"| node_search
node_plugin -.->|"probes optional backend"| node_comfy
node_diary -.->|"persists entries"| node_statefiles

click node_plugin "https://github.com/mearihaka/dsh-longing/blob/main/src/index.js"
click node_config "https://github.com/mearihaka/dsh-longing/blob/main/src/config.js"
click node_statefiles "https://github.com/mearihaka/dsh-longing/blob/main/src/index.js"
click node_curve "https://github.com/mearihaka/dsh-longing/blob/main/src/curve.js"
click node_events "https://github.com/mearihaka/dsh-longing/blob/main/src/events.js"
click node_autoevent "https://github.com/mearihaka/dsh-longing/blob/main/src/auto-event.js"
click node_anchor "https://github.com/mearihaka/dsh-longing/blob/main/src/anchor.js"
click node_mood "https://github.com/mearihaka/dsh-longing/blob/main/src/mood.js"
click node_unlock "https://github.com/mearihaka/dsh-longing/blob/main/src/unlock.js"
click node_behavior "https://github.com/mearihaka/dsh-longing/blob/main/src/behavior.js"
click node_prompt "https://github.com/mearihaka/dsh-longing/blob/main/src/prompt.js"
click node_diary "https://github.com/mearihaka/dsh-longing/blob/main/src/diary.js"
click node_reflect "https://github.com/mearihaka/dsh-longing/blob/main/src/reflect.js"
click node_recall "https://github.com/mearihaka/dsh-longing/blob/main/src/recall.js"
click node_proactive "https://github.com/mearihaka/dsh-longing/blob/main/src/proactive.js"
click node_curio "https://github.com/mearihaka/dsh-longing/blob/main/src/curio.js"
click node_panel "https://github.com/mearihaka/dsh-longing/blob/main/panel/index.html"

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,node_config,node_user toneBlue
class node_statefiles,node_curve,node_events,node_autoevent,node_anchor toneAmber
class node_mood,node_unlock,node_behavior,node_prompt,node_diary,node_reflect,node_recall,node_proactive,node_curio toneMint
class node_panel toneRose
class node_channel,node_search,node_comfy,node_dsh toneIndigo
```

## Components

### Plugin Runtime

- [Plugin Orchestrator](https://github.com/mearihaka/dsh-longing/blob/main/src/index.js): `src/index.js`
- [Configuration Schema](https://github.com/mearihaka/dsh-longing/blob/main/src/config.js): `src/config.js`

### State Engine

- [Persistent State](https://github.com/mearihaka/dsh-longing/blob/main/src/index.js): `src/index.js`
- [State Dynamics](https://github.com/mearihaka/dsh-longing/blob/main/src/curve.js): `src/curve.js`
- [Event Effects](https://github.com/mearihaka/dsh-longing/blob/main/src/events.js): `src/events.js`
- [Event Detection](https://github.com/mearihaka/dsh-longing/blob/main/src/auto-event.js): `src/auto-event.js`
- [Activity Tracking](https://github.com/mearihaka/dsh-longing/blob/main/src/anchor.js): `src/anchor.js`

### Character Experience

- [Scene and Mood](https://github.com/mearihaka/dsh-longing/blob/main/src/mood.js): `src/mood.js`
- [Progressive Unlocks](https://github.com/mearihaka/dsh-longing/blob/main/src/unlock.js): `src/unlock.js`
- [Reply Behavior](https://github.com/mearihaka/dsh-longing/blob/main/src/behavior.js): `src/behavior.js`
- [Prompt Rendering](https://github.com/mearihaka/dsh-longing/blob/main/src/prompt.js): `src/prompt.js`
- [Mood Diary](https://github.com/mearihaka/dsh-longing/blob/main/src/diary.js): `src/diary.js`
- [Diary Reflection](https://github.com/mearihaka/dsh-longing/blob/main/src/reflect.js): `src/reflect.js`
- [Event Recall](https://github.com/mearihaka/dsh-longing/blob/main/src/recall.js): `src/recall.js`
- [Proactive Gates](https://github.com/mearihaka/dsh-longing/blob/main/src/proactive.js): `src/proactive.js`
- [Curiosity Search](https://github.com/mearihaka/dsh-longing/blob/main/src/curio.js): `src/curio.js`

### User Interfaces

- [Web Panel](https://github.com/mearihaka/dsh-longing/blob/main/panel/index.html): `panel/index.html`

### External Integrations

- **Channel Plugin**
- **Web Search**
- **ComfyUI**

### Other components

- **Chat User**
- **DSH Host**

## Connections

- DSH Host → Plugin Orchestrator: loads plugin (evidence: `README.md`)
- Chat User → Channel Plugin: sends messages (evidence: `README.md`)
- Channel Plugin → Plugin Orchestrator: reports activity (evidence: `README.md`)
- Plugin Orchestrator → Configuration Schema: uses settings (evidence: `src/index.js`)
- Plugin Orchestrator → Persistent State: reads and writes (evidence: `src/index.js`)
- Plugin Orchestrator → State Dynamics: updates state (evidence: `src/index.js`)
- Plugin Orchestrator → Event Detection: detects events (evidence: `src/index.js`)
- Plugin Orchestrator → Event Effects: applies events (evidence: `src/index.js`)
- Plugin Orchestrator → Activity Tracking: tracks activity (evidence: `src/index.js`)
- Plugin Orchestrator → Mood Diary: maintains diary (evidence: `src/index.js`)
- Plugin Orchestrator → Diary Reflection: requests reflection (evidence: `src/index.js`)
- Plugin Orchestrator → Curiosity Search: searches topics (evidence: `src/index.js`)
- Plugin Orchestrator → Prompt Rendering: builds injections (evidence: `src/index.js`)
- Plugin Orchestrator → Channel Plugin: provides context (evidence: `README.md`)
- State Dynamics → Prompt Rendering: supplies calculations (evidence: `src/prompt.js`)
- Event Effects → State Dynamics: changes shared state (evidence: `src/events.js`)
- Prompt Rendering → Scene and Mood: renders scene (evidence: `src/prompt.js`)
- Prompt Rendering → Progressive Unlocks: renders boundaries (evidence: `src/prompt.js`)
- Prompt Rendering → Reply Behavior: adds reply guidance (evidence: `src/prompt.js`)
- Prompt Rendering → Event Recall: includes remembered events
- Plugin Orchestrator → Proactive Gates: checks initiative (evidence: `src/index.js`)
- Plugin Orchestrator → Web Panel: serves panel (evidence: `README.md`)
- Web Panel → Plugin Orchestrator: requests status (evidence: `README.md`)
- Curiosity Search → Web Search: queries topics (evidence: `src/curio.js`)
- Plugin Orchestrator → ComfyUI: probes optional backend (evidence: `src/index.js`)
- Mood Diary → Persistent State: persists entries (evidence: `src/index.js`)
