384961890-ui / pawin-brain-deepseek-harness

Listed

A brain-inspired runtime for DeepSeek Harness agents — remember, self-correct, learn. v0.1 ships memory (injection, notes, recall), 100% covered.

mainSession View source

Installation

npx -y @deepseek-ai/dsh plugin --profile web add github:384961890-ui/pawin-brain-deepseek-harness

This installation command is an unverified starting point generated from the GitHub repository address.

README

Maintainer-authored documentation snapshot.

View on GitHub ↗
Commit a0319f6Synced Aug 18, 2026

Pawin Brain

Pawin Brain · DeepSeek Harness

简体中文

A brain-inspired agent runtime.
Remember · self-correct · learn — v0.1 starts with memory, the foundation of both.

Built for DeepSeek Harness MIT License 100% coverage 84 tests passing TypeScript strict

Quick start · How it works · Security · Configuration · Development


[!NOTE] This is an independent community plugin by the Pawin project — it is not an official DeepSeek product.

The brain idea

Pawin Brain is not a memory plugin — it is a brain-inspired runtime for agents, built around one loop:

remember ──► self-correct ──► learn
   ▲                             │
   └─────────────────────────────┘
  • Remember — an agent that cannot recall its past cannot learn from it.
  • Self-correct — surface contradictions, repeated failures, and missing evidence instead of glossing over them.
  • Learn — a lesson only counts when a later, different session changes its behavior, not when it merely writes a note about itself.

v0.1 ships the remember stage — the hippocampus. It is deliberately the foundation: every later stage reads what this one wrote down.

What v0.1 ships

The first, fully-tested slice of the runtime, for DeepSeek Harness:

  1. Per-turn injection — recent diary entries enter the model's context at the start of every turn.
  2. brain_note — append a fact worth remembering to today's diary.
  3. brain_recall — multi-word AND search over past diary entries.

Memory is a directory of plain Markdown files. No database, no network, no external service. Delete the directory and all memory is gone.

Roadmap

The later stages of the loop — self-correct (conflict monitoring, repeated-failure detection) and learn (behavior-differential proof) — are under active development and will ship as later versions. Memory is released first because every other stage depends on it.

<memoryRoot>/
└── diary/
    ├── 2026-08-13.md   # append-only, one [HH:MM] entry per line
    └── 2026-08-12.md

Quick start

Run from a DeepSeek Harness checkout:

pnpm dsh web --patch examples/demo.cordis.yml

Open http://127.0.0.1:3080 and say:

Note down that my favorite drink is oolong tea.

Then, in a new session (no need to restart the server):

What is my favorite drink? Check memory with brain_recall.

The agent recalls it from the diary on disk.

How it works

flowchart LR
    U[User turn] --> P[agent/pre-step]
    P -->|inject today's diary| M[Model request]
    M -->|calls| N[brain_note]
    M -->|calls| R[brain_recall]
    N --> D[(diary/YYYY-MM-DD.md)]
    R --> D
    D -->|next turn| P
  • Injection hooks agent/pre-step (waterfall) and appends one source-attributed message per turn — never more than once a turn, and never when the diary is empty.
  • Tools go through the normal ctx.tools registry: runtime argument validation, sandbox policy, approval, and teardown all behave as with any first-party tool.
  • Storage is append-only with O_APPEND; concurrent appends do not clobber each other.

Security

dsh-brain treats the diary as untrusted input and the filesystem as hostile:

BoundaryBehavior
DatesStrict YYYY-MM-DD calendar-roundtrip validation; 2026-02-30 is rejected
Path traversalRejected at the date-parameter level; a second join check stays as defense
Symbolic linksRejected at three layers: memory root, diary/ dir, and each diary file
ContentNUL bytes, overlong lines, and over-budget appends are rejected loudly
ReadsByte-budgeted with newest-tail truncation; 64 MB hard cap per file
WritesO_APPEND atomic appends; concurrent writes never interleave
ConfigInvalid configuration fails at plugin load — never silently

Configuration

FieldDefaultMeaning
memoryRoot~/.dsh-brain-memoryMemory root (absolute or ~-prefixed)
injectDiaryDays2Recent diary days injected per turn (incl. today), 1–7
injectMaxBytes8192Total injection byte budget
noteMaxBytes8192brain_note per-call byte budget
recallMaxResults20brain_recall max returned hits, 1–500
recallSnippetChars240Per-hit display characters, 1–4000
recallScanDays30brain_recall scan window in calendar days, 1–365

Example mount entry (examples/demo.cordis.yml):

- insert:
    - id: dsh-brain
      name: '/absolute/path/to/dsh-brain/src/index.ts'
      config:
        memoryRoot: '~/.dsh-brain-memory'

Development

This plugin is developed as a standalone directory inside a DeepSeek Harness checkout (its @deepseek-ai/* dependencies resolve through the harness workspace).

# unit tests + real-composition test; per-file 100% coverage gate
./node_modules/.bin/vitest run --config vitest.config.ts --coverage

# typecheck (paths map every @deepseek-ai/* package to its built lib/types)
./node_modules/.bin/tsc --noEmit -p tsconfig.json

# lint (harness .oxlintrc.json)
./node_modules/.bin/oxlint -c .oxlintrc.json src tests

Current state: 84 tests passing, 100% coverage across statements / branches / functions / lines, typecheck and lint clean.

The real-composition test boots a headless assembly through the harness's own Loader; a deterministic mock LLM really calls brain_note and brain_recall, and the test asserts that the second turn's injection sees the first turn's write.

License

MIT © Pawin

Not affiliated with or endorsed by DeepSeek.

Project files and signals

Shown items are public repository signals detected in the directory snapshot.

TestsDetected
ExamplesDetected

Repository information

Language
TypeScript
License
MIT
Last updated
Aug 13, 2026, 4:12 PM

Install deliberately

Review source code, permissions, lifecycle hooks, dependencies and network access. Test untrusted plugins in an isolated environment.