Skills Plugins MCP Prompt Model 导航 博客 资讯 我的中心
会话与消息 #deepseek-harness#dsh-plugin#fts5#knowledge-base#sqlite#ai-coding

dsh-knowledge-sqlite

Cross-session knowledge for DeepSeek Harness: ctx.knowledge service + knowledge_* tools, SQLite FTS5 trigram retrieval (CJK substring) with L1 query expansion. V1.11 contract (write/update/search/list/delete + budget + events + error codes).

ninjasln-labs @ninjasln-labs ⬇ 2 ★ 0 main

安装

dsh plugin --profile web add github:ninjasln-labs/dsh-knowledge-sqlite
下载安装清单

需要可复现安装时,可在仓库后追加 #commit 固定提交。

Cross-session knowledge for DeepSeek Harness: ctx.knowledge service + knowledge_* tools, SQLite FTS5 trigram retrieval (CJK substring) with L1 query expansion. V1.11 contract (write/update/search/list/delete + budget + events + error codes).

该插件未提供要点说明,请参考仓库 README。

deepseek-harnessdsh-pluginfts5knowledge-basesqliteai-coding
  1. 安装并启动 DeepSeek Harness:npx @deepseek-ai/dsh web
  2. 在终端执行上面的安装命令(CLI 会解析插件并核验来源)
  3. 用 dsh plugins list 确认已安装,必要时重启 Harness 生效

插件以当前 dsh 进程的权限运行,安装时可能执行代码。请先通读仓库源码与许可证,确认无破坏性命令与越权访问;本站只做索引,不对第三方插件安全性作担保。

代码仓库github.com/ninjasln-labs/dsh-knowledge-sqlite
许可证MIT
主要语言main
下载量2
GitHub 星标0
最近推送2026-09-05
收录日期2026-09-19
分类会话与消息

事实信息来自公开插件目录快照(2026-10-01),介绍文案由本站再加工。

以下为插件仓库 README 全文(原始内容,由公开目录抓取整理)。

# dsh-knowledge-sqlite

[English](README.md) | [中文](README.zh.md)

[![npm version](https://img.shields.io/npm/v/dsh-knowledge-sqlite)](https://www.npmjs.com/package/dsh-knowledge-sqlite)
[![License](https://img.shields.io/npm/l/dsh-knowledge-sqlite)](LICENSE)
[![GitHub stars](https://img.shields.io/github/stars/NinjaSln-labs/dsh-knowledge-sqlite?style=social)](https://github.com/NinjaSln-labs/dsh-knowledge-sqlite)

> Chinese (README.zh.md) is the authoritative version; the English translation may lag behind.

Cross-session knowledge for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness): a `ctx.knowledge` service seam plus `knowledge_*` model tools, backed by SQLite FTS5 **trigram** retrieval (CJK substring search) with **L1 query expansion**.

Implements the [V1.11 knowledge seam proposal](docs/DESIGN.md) (11-round reviewed design, community proposal — not an official DSH feature). Contract: `write/update/search/list/delete` + budget + events + error codes.

```sh
dsh plugin add dsh-knowledge-sqlite
```

## Why trigram FTS5

DSH's current full-text search uses `unicode61`, which cannot match Chinese substrings. Measured on the project's evaluation suite (see [EXPERIMENTS](docs/EXPERIMENTS.md)):

| Retrieval stage | Hard rewritten queries (14, 512-item corpus) | Real human queries (17 targeted, 522-item corpus) |
|---|---|---|
| unicode61 (baseline, no CJK substring) | 0% | — |
| L0 pure lexical (trigram) | 7% | 65% |
| **L1 (default): + query expansion** | **21–64%** (prototype live: 43–64%) | **65%** (prototype live; reasoner variants measured 82%) |
| L2 (opt-in): + write-time enrichment | 50% | 88% (with n-enrichment) |

Acceptance gates (from V1.11): L1 recall@1 ≥ 30% on the hard set, ≥ 50% on the human set — both passed by the live prototype (kpro-2) and reproduced exactly by this bundle's SQLite layer (A 7% / C 21% / D 50% / human-A 65%, per-query rank identical).

## What it does

- **`knowledge_write`** — write a durable item; indexed immediately, zero LLM. `dedupeKey` upserts with stable id (`hash(workspace+scope+dedupeKey)`). **Ask-gated** (needs user approval; headless `approval=never` deployments auto-deny).
- **`knowledge_search`** — trigram OR + BM25, top-N; **L1 query expansion** by default (one small model call per query, cached per normalized query, `timeoutMs` fallback to lexical with `degraded: 'lexical'` metadata — never a tool error). `expand: false` or caller `variants` skips the call.
- **`knowledge_update`** — correction path; preserves id/provenance/stamps; `scope`/`dedupeKey` immutable after write.
- **`knowledge_list`** — auditability, cursor paging (newest first), `expired`/`deleted` flags.
- **`knowledge_delete`** — tombstone; expired items return `false`.
- **Events** — `knowledge/written` / `knowledge/updated` / `knowledge/deleted` with `{ id, scope, importance }`.
- **`knowledge_probe`** — evaluation-suite harness (stage-3 gates) that seeds the experiment corpus and reports arm recall + contract checks.

## Authorization & trust (V1.11)

- **Workspace isolation** — identity is the caller's canonical cwd (`session.header.cwd`); cross-workspace calls never see content.
- **Ask gating** — `knowledge_write`/`knowledge_delete` go through the tools approval seam.
- **Global scope** — `allowedGlobalWriters` allowlist (agent/preset ids); headless denial is explicit `write-rejected`.
- **`authorTier`** — `human | explicit | derived | llm`, stamped by the tool layer (never caller input; spoofing → `write-rejected`). Hits carry `provenance: original | enriched` and `authorTier`.
- **Session scope** — scratch memory visible only to the owning session.

## Configuration

Plugin row config (all optional, defaults are the V1.11 proposal defaults):

```yaml
# cordis.patch.yml / profile row
- id: knowledge-sqlite
  name: 'dsh-knowledge-sqlite'
  config:
    gating: 'ask'                              # 'ask'(默认,V1.11):write/delete 经 approval 确认;'none':跳过门控自动放行
    databasePath: '/custom/data/knowledge.sqlite'   # 默认 $DSH_HOME/knowledge.sqlite(DSH_HOME 缺省 ~/.dsh)
    maxContentTokens: 2048
    queryExpansion:
      enabled: true
      model: ''                                # unset = session default model
      maxOutputTokens: 300
      timeoutMs: 3000   # 默认值(0.1.5 起)
      cache: true
    retrieval:
      topN: 20
      maxQueryTrigrams: 0                      # 0 = unlimited; cap 24 needs idf-priority truncation (see EXPERIMENTS)
      maxCandidates: 200
    authorization:
      allowedGlobalWriters: []                 # agent/preset ids allowed to write global scope
    corpusPath: 'research/memory-knowledge-seam/experiments/memory-experiment'   # probe corpus base (relative to workspace)
```

## Storage layout

- Single SQLite file (`items` + two FTS5 trigram tables: `items_fts_base` = content only, `items_fts_rich` = content + enrichment columns joined).
- Upsert uses `INSERT … ON CONFLICT DO UPDATE` (rowid stays stable so FTS links survive — `INSERT OR REPLACE` breaks them).
- Search filters `deleted`/TTL/workspace at query time; ranking is `bm25()`.
- `dedupeKey` uniqueness = `(workspace_id, scope, dedupe_key)` (non-partial unique index; SQLite NULLs don't conflict).

## Development

```sh
npm install
npm run build          # tsc(纯 TS,无需装饰器转换)
npm test               # vitest:38 项(store 19 + service 19)
node test-smoke.mjs    # SQLite 层冒烟:复现 A 7% / C 21% / D 50% / human-A 65% + 契约检查
```

测试覆盖(提案测试矩阵裁剪):契约往返、dedupeKey 作用域 upsert(确定性 id)、打标伪造拒绝、
global allowlist、scope/dedupeKey 不可变、TTL(过滤/list 标记/过期 delete=false)、tombstone、
跨 workspace / session / global 隔离、missing-key、closed、maxContentTokens、分页、富化字段检索、
L1 扩展(mock llm:命中/缓存/超时降级/失败降级)、budget 截断、事件发射、ask 门控监听器、
probe 实验套件(A/C/D 确定性臂精确复现 + contract 全过)。

## Design & evidence

- [DESIGN](docs/DESIGN.md) — V1.11 proposal full text (community design, not official)
- [REVIEWS](docs/REVIEWS.md) — 11-round review chain summary (0C/0M/0m)
- [EXPERIMENTS](docs/EXPERIMENTS.md) — RESULTS-v3 + prototype verification (kpro-2, live L1, contract 11/11, ask-gate)
- Prototype workbench: `research/memory-knowledge-seam/experiments/prototype/` (SQLite blueprint, JS↔FTS5 calibration 0/72 mismatch, dynamic-plugin verification)

## ⭐ Support

If this plugin helps you, consider giving it a ⭐ Star on [GitHub](https://github.com/NinjaSln-labs/dsh-knowledge-sqlite) — it keeps the project going. Issues and PRs are welcome.

## License

[MIT](LICENSE) © ninjasln

数据来源:公开的 DeepSeek Harness 插件目录与各插件 GitHub 仓库。本站为独立第三方目录,与 DeepSeek、幻方(High-Flyer)及插件作者均无隶属或背书关系。

每日精选 Skill 推荐,免费送到你邮箱

输入邮箱,每天接收一个精选 AI Agent 技能推荐。完全免费,持续更新。

提交后我们会发送一封确认邮件,点击邮件里的链接才会开始收信。

完全免费,取消任意时间。我们不会发送垃圾邮件。