# mengxinsu/dsh-viya-memory architecture

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

- Interactive diagram: https://gitdiagram.com/mengxinsu/dsh-viya-memory
- Repository: https://github.com/mengxinsu/dsh-viya-memory

## Overview

viya-memory is a DeepSeek Harness plugin that provides seven model-facing tools for managing Markdown memory cards in a user-owned Obsidian vault. The main workflow is to save cards, search and read them, then update or link them; forgetting and stats provide lifecycle and maintenance operations. The plugin also injects the hand-written user.md into the system prompt. The repository is a single-file runtime, so the component paths below share lib/index.js. Some internal wiring is documented in the README but not visible in the sampled excerpts.

Main entry points: [`lib/index.js`](https://github.com/mengxinsu/dsh-viya-memory/blob/main/lib/index.js) (Tool registration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Host integration"]
  node_hostplugin["Plugin apply<br/>[index.js]"]
  node_toolregistry["Tool registration<br/>[index.js]"]
  node_prompt["Prompt injection<br/>[index.js]"]
end

subgraph group_tools["Memory tools"]
  node_save["Save cards<br/>[index.js]"]
  node_search["Search cards<br/>[index.js]"]
  node_read["Read cards<br/>[index.js]"]
  node_update["Update cards<br/>[index.js]"]
  node_link["Link cards<br/>[index.js]"]
  node_forget["Forget cards<br/>[index.js]"]
  node_stats["Vault stats<br/>[index.js]"]
end

subgraph group_safety["Card handling"]
  node_cardformat["Markdown cards<br/>[index.js]"]
  node_guardrails["Path and content checks<br/>[index.js]"]
  node_assetmove["Image handling<br/>[index.js]"]
end

subgraph group_vault["Vault data"]
  node_vault["Obsidian vault"]
  node_trash["Trash and assets"]
  node_userfile["user.md"]
end

node_model(("Model / user"))

node_hostplugin -->|"registers tools"| node_toolregistry
node_model -->|"invokes tools"| node_toolregistry
node_hostplugin -->|"injects prompt"| node_prompt
node_prompt -->|"reads"| node_userfile
node_toolregistry -->|"dispatches"| node_save
node_toolregistry -->|"dispatches"| node_search
node_toolregistry -->|"dispatches"| node_read
node_toolregistry -->|"dispatches"| node_update
node_toolregistry -->|"dispatches"| node_link
node_toolregistry -->|"dispatches"| node_forget
node_toolregistry -->|"dispatches"| node_stats
node_save -->|"validates"| node_guardrails
node_update -->|"validates"| node_guardrails
node_link -->|"validates"| node_guardrails
node_forget -->|"validates"| node_guardrails
node_save -->|"moves images"| node_assetmove
node_save -->|"writes cards"| node_vault
node_search -->|"scans cards"| node_vault
node_read -->|"reads cards"| node_vault
node_update -->|"updates cards"| node_vault
node_link -->|"writes both cards"| node_vault
node_forget -->|"previews or deletes"| node_vault
node_forget -->|"soft-deletes"| node_trash
node_stats -->|"scans cards"| node_vault
node_stats -->|"counts trash"| node_trash
node_save -->|"serializes"| node_cardformat
node_update -->|"rewrites"| node_cardformat
node_link -->|"records links"| node_cardformat
node_assetmove -->|"stores images"| node_trash

click node_hostplugin "https://github.com/mengxinsu/dsh-viya-memory/blob/main/lib/index.js"
click node_toolregistry "https://github.com/mengxinsu/dsh-viya-memory/blob/main/lib/index.js"
click node_prompt "https://github.com/mengxinsu/dsh-viya-memory/blob/main/lib/index.js"
click node_save "https://github.com/mengxinsu/dsh-viya-memory/blob/main/lib/index.js"
click node_search "https://github.com/mengxinsu/dsh-viya-memory/blob/main/lib/index.js"
click node_read "https://github.com/mengxinsu/dsh-viya-memory/blob/main/lib/index.js"
click node_update "https://github.com/mengxinsu/dsh-viya-memory/blob/main/lib/index.js"
click node_link "https://github.com/mengxinsu/dsh-viya-memory/blob/main/lib/index.js"
click node_forget "https://github.com/mengxinsu/dsh-viya-memory/blob/main/lib/index.js"
click node_stats "https://github.com/mengxinsu/dsh-viya-memory/blob/main/lib/index.js"
click node_cardformat "https://github.com/mengxinsu/dsh-viya-memory/blob/main/lib/index.js"
click node_guardrails "https://github.com/mengxinsu/dsh-viya-memory/blob/main/lib/index.js"
click node_assetmove "https://github.com/mengxinsu/dsh-viya-memory/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_hostplugin,node_toolregistry,node_prompt,node_model toneBlue
class node_save,node_search,node_read,node_update,node_link,node_forget,node_stats toneAmber
class node_cardformat,node_guardrails,node_assetmove toneMint
class node_vault,node_trash,node_userfile toneRose
```

## Components

### Host integration

- [Plugin apply](https://github.com/mengxinsu/dsh-viya-memory/blob/main/lib/index.js): `lib/index.js`
- [Tool registration](https://github.com/mengxinsu/dsh-viya-memory/blob/main/lib/index.js): `lib/index.js`
- [Prompt injection](https://github.com/mengxinsu/dsh-viya-memory/blob/main/lib/index.js): `lib/index.js`

### Memory tools

- [Save cards](https://github.com/mengxinsu/dsh-viya-memory/blob/main/lib/index.js): `lib/index.js`
- [Search cards](https://github.com/mengxinsu/dsh-viya-memory/blob/main/lib/index.js): `lib/index.js`
- [Read cards](https://github.com/mengxinsu/dsh-viya-memory/blob/main/lib/index.js): `lib/index.js`
- [Update cards](https://github.com/mengxinsu/dsh-viya-memory/blob/main/lib/index.js): `lib/index.js`
- [Link cards](https://github.com/mengxinsu/dsh-viya-memory/blob/main/lib/index.js): `lib/index.js`
- [Forget cards](https://github.com/mengxinsu/dsh-viya-memory/blob/main/lib/index.js): `lib/index.js`
- [Vault stats](https://github.com/mengxinsu/dsh-viya-memory/blob/main/lib/index.js): `lib/index.js`

### Card handling

- [Markdown cards](https://github.com/mengxinsu/dsh-viya-memory/blob/main/lib/index.js): `lib/index.js`
- [Path and content checks](https://github.com/mengxinsu/dsh-viya-memory/blob/main/lib/index.js): `lib/index.js`
- [Image handling](https://github.com/mengxinsu/dsh-viya-memory/blob/main/lib/index.js): `lib/index.js`

### Vault data

- **Obsidian vault**
- **Trash and assets**
- **user.md**

### Other components

- **Model / user**

## Connections

- Plugin apply → Tool registration: registers tools
- Model / user → Tool registration: invokes tools
- Plugin apply → Prompt injection: injects prompt
- Prompt injection → user.md: reads
- Tool registration → Save cards: dispatches
- Tool registration → Search cards: dispatches
- Tool registration → Read cards: dispatches
- Tool registration → Update cards: dispatches
- Tool registration → Link cards: dispatches
- Tool registration → Forget cards: dispatches
- Tool registration → Vault stats: dispatches
- Save cards → Path and content checks: validates
- Update cards → Path and content checks: validates
- Link cards → Path and content checks: validates
- Forget cards → Path and content checks: validates
- Save cards → Image handling: moves images
- Save cards → Obsidian vault: writes cards
- Search cards → Obsidian vault: scans cards
- Read cards → Obsidian vault: reads cards
- Update cards → Obsidian vault: updates cards
- Link cards → Obsidian vault: writes both cards
- Forget cards → Obsidian vault: previews or deletes
- Forget cards → Trash and assets: soft-deletes
- Vault stats → Obsidian vault: scans cards
- Vault stats → Trash and assets: counts trash
- Save cards → Markdown cards: serializes
- Update cards → Markdown cards: rewrites
- Link cards → Markdown cards: records links
- Image handling → Trash and assets: stores images
