dsh-magic-context
Agent 与会话 活跃维护

dsh-magic-context

xiaohj233/dsh-magic-context

轻量级社区移植插件,原生支持跨harness共享SQLite持久化记忆,可针对指定harness场景做行级隔离,无需额外配置即可实现多harness间的记忆同步与权限管控,内存占用低开箱即用体验流畅。

3
Stars 标星
0
Forks 分支
3
Watchers 关注
0
Open Issues
TypeScript
主要语言
MIT
开源协议
1.5 MB
仓库大小
1 个月前
最后推送
一键安装扩展 / 插件指令
dsh plugin --profile web add github:xiaohj233/dsh-magic-context
git clone https://github.com/xiaohj233/dsh-magic-context.git
git clone git@github.com:xiaohj233/dsh-magic-context.git
README.md main

Magic Context for DSH

[English](https://github.com/xiaohj233/dsh-magic-context/blob/main/README.en.md) | **中文** ![Version](https://cdnimage-cache.doubi.ren/?url=https://img.shields.io/badge/version-0.1.1-blue.svg) ![DSH](https://cdnimage-cache.doubi.ren/?url=https://img.shields.io/badge/DSH-0.1.0--rc.6-111827.svg) ![Magic Context](https://cdnimage-cache.doubi.ren/?url=https://img.shields.io/badge/Magic%20Context-0.36.1-7C3AED.svg) ![Harness](https://cdnimage-cache.doubi.ren/?url=https://img.shields.io/badge/harness-dsh-5391FE.svg) ![Community](https://cdnimage-cache.doubi.ren/?url=https://img.shields.io/badge/community-port-0F766E.svg) ![Tests](https://cdnimage-cache.doubi.ren/?url=https://img.shields.io/badge/tests-194%2F194-brightgreen.svg) ![License](https://cdnimage-cache.doubi.ren/?url=https://img.shields.io/badge/license-MIT-brightgreen.svg) **社区移植**:将 [Magic Context](https://github.com/cortexkit/magic-context) 移植到 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)(DSH)的独立社区项目。 与官方 DSH 及官方 Magic Context 均无隶属关系,能力对齐情况见 [功能特性](https://github.com/xiaohj233/dsh-magic-context/blob/main/docs/FEATURES.md)。 [E2E 环境](https://github.com/xiaohj233/dsh-magic-context/blob/main/e2e/README.md)

项目定位

一个把 Magic Context 移植到 DeepSeek Harness 的适配层:让 DSH 会话使用
Magic Context 的知识注入、上下文管理与记忆能力,并与 OpenCode/Pi 的
Magic Context 共享同一 SQLite 记忆库harness='dsh' 行隔离),
OpenCode/Pi 行为保持不变。

适合这些场景:

  • 在 DSH 中复用已有的 Magic Context 记忆(与 OpenCode/Pi 共享)。
  • 希望 DSH 会话获得 m0/m1 知识注入、§N§ 标签、historian 压缩、
    Dreamer 定时任务等能力。
  • 想要 /ctx-* 工具族(search/memory/note/expand/reduce/embed/recomp/wrapup)
    与 todowrite 的 DSH 用户。

能力对齐:注入(m0/m1 双消息、首轮即见、§N§ 首轮打标)、压缩(低上下文
窗口 chunk 预算、historian 独立模型路由、发布后 <session-history> 折叠)、
nudge 双通道、heuristic cleanup、配置桥接——均与 Magic Context 0.36.1
(Pi/OpenCode)语义对齐。

安装

在 DSH profile 的 package.json 中(profile 目录即 $DSH_HOME/profiles/<name>/
dsh plugin --profile <name> install 会自动在该目录执行):

{
  "dependencies": {
    "dsh-magic-context": "github:xiaohj233/dsh-magic-context#v0.1.0&path:/packages/dsh-plugin"
  },
  "dsh": {
    "profile": {
      "bundles": ["dsh-magic-context"]
    }
  }
}

⚠️ dsh.profile.bundles保留你 profile 现有的条目(如
@deepseek-ai/dsh-base@deepseek-ai/dsh-web-app@deepseek-ai/dsh-headless
等),只追加 "dsh-magic-context"

然后安装依赖并重启 dsh:

dsh plugin --profile <name> install
# 或:cd $DSH_HOME/profiles/<name> && pnpm install

重启后初始化:

dsh-magic-context setup    # 生成 magic-standard 薄 preset
dsh-magic-context doctor   # 验证安装

为新会话选择 magic-standard preset(Web UI: Settings → Agent preset,或
settings.yaml: agent-presets.default: magic-standard)。

⚠️ 使用前提:Magic 的 agent 能力(知识注入、ctx_ 工具、/ctx- 命令、
historian、Dreamer、Magic 压缩策略)只在新会话选择 magic-standard 预设时
加载
。未选择该预设的会话完全按官方语义运行——仅 host 半侧常驻
(共享库初始化 + 状态卡/诊断端点),不会有任何 Magic 干预。想让插件默认
生效,把 settings.yamlagent-presets.default 设为 magic-standard

依赖包(dsh-magic-context-adapter)由主包的 github: 依赖自动解析,无需单独安装。

首次会话自动创建共享 SQLite(~/.local/share/cortexkit/magic-context/context.db)。

功能一览

  • 知识模式:m0/m1 baseline 注入(含 Mural 图像)、auto-search、§N§ tags
  • 上下文管理:DshTranscript + SurfaceMutationCoordinator(CAS + outbox saga)、
    historian 后台 compartment、Magic 压缩策略、缓存分类 SOFT+/SOFT/HARD
  • 自动化:Dreamer 全部任务、Sidekick /ctx-aug、/ctx-recomp /ctx-wrapup
    /ctx-session-upgrade、/ctx-embed、feedback 桥接
  • 维护:setup/doctor、升级契约门、无写回安全(shipped preset 只读挂载)
  • Web:状态卡 + Remote 诊断端点

完整对照见 docs/FEATURES.md

验证状态

  • 177/177 测试全绿(dsh-plugin)+ adapter-api 14/14 + typecheck 0 错误
  • 已在隔离的非全局 DSH 验证安装:npm 安装 → setup(薄 preset)→ doctor 6/6 →
    薄 preset 挂载 → 知识注入(m0/§N§ tags)→ 真实模型链路(本地中转
    deepseek-v4-flash 响应 Magic 注入的上下文)→ 共享 SQLite harness='dsh' 行写入
  • OpenCode/Pi 零改动(共享 DB 兼容)

约束与边界

  • 不修改 DSH 源码;不拦截/改写 llm/stream messages[];OpenCode/Pi 行为不变。
  • 兼容基线:DSH 0.1.0-rc.6(升级先跑契约门)。
  • 已知边界见 docs/FEATURES.md(差异记录)。

许可证

MIT(与 Magic Context、DSH 一致)。上游版权声明见各包 NOTICE