DeepSeek Harness 插件

GooDAnDReaDY/dsh-context-lens

Star 数 ★ 3 下载量(近 30 天) 6,434 分类 工具与能力 收录于 2026-09-01 npm @goodandready/dsh-context-lens

DeepSeek Harness 的 AST 上下文压缩、测试日志过滤与 Token 预算守卫:剔除冗余语法、精简日志噪声,并强制执行 Token 上限以防止上下文窗口溢出。

安装

# npm 包(预构建)

dsh plugin --profile web add @goodandready/dsh-context-lens

# GitHub 源码(首次需按提示配置 allowBuilds 构建授权后重试)

dsh plugin --profile web add github:GooDAnDReaDY/dsh-context-lens

装任何插件都等于在你的机器上跑第三方代码,权限和你本人一样大——能读你的文件、用你的凭据、访问网络,工具审批管不到它。GitHub 来源的插件还会在安装时执行构建脚本——pnpm 默认拦截,所以安装可能停在 ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED 或 ERR_PNPM_IGNORED_BUILDS;dsh 会打印出需要添加的确切键名,把它加进该 profile 的 pnpm-workspace.yaml 的 allowBuilds 下,重跑一次即可装上。放行构建本身就是一次信任判断:请只安装可信来源,并尽量锁定 commit(github:owner/repo#sha)。

README


⚡ 核心定位与职责划分

说明:
上下文预算控制、Token 计数、工具输出头尾截断 (dsh-compaction-tool-result-pruner) 以及大文件溢出落盘 (dsh-spill-policy, dsh-token-meter) 由 DSH 核心引擎 (>= 0.1.5) 原生负责。
dsh-context-lens 专注于核心不具备的能力 —— 语义压缩:

  1. AST 代码骨架生成:提取函数签名、接口、类型定义及文档注释,去除冗长实现体(支持 9+ 种语言)。
  2. 焦点路径机制:正在编辑的文件保留全量内容,周边工作区文件生成骨架。
  3. 测试与构建日志压缩:保留失败信息、错误栈及汇总结果,剔除冗余输出。
graph LR
    subgraph RawContext [原始输入]
        Code[📁 源代码] --> Lens[dsh-context-lens 语义引擎]
        Logs[📋 测试与构建日志] --> Lens
    end

    subgraph Lens [语义压缩处理]
        Lens --> Focus{路径焦点判断}
        Focus -->|聚焦文件| FullCode[保留完整代码]
        Focus -->|周边文件| AST[AST 骨架提取]
        Lens --> LogCompress[日志压缩: 错误/堆栈/汇总]
    end

    subgraph Output [优化后上下文]
        FullCode --> Agent[🤖 Agent 上下文]
        AST --> Agent
        LogCompress --> Agent
        Agent --> Core[⚙️ DSH 核心截断与溢出策略]
    end

    style RawContext fill:#1e1e2e,stroke:#89b4fa,stroke-width:2px,color:#cdd6f4
    style Lens fill:#181825,stroke:#cba6f7,stroke-width:2px,color:#cdd6f4
    style Output fill:#11111b,stroke:#a6e3a1,stroke-width:2px,color:#cdd6f4

🛠️ Agent 工具参考 (归并至 2 个工具)

所有工具完全符合 DeepSeek Harness 规范,output.render 统一返回 ContentBlock[] 数组。

工具名 操作模式 参数 描述
context_lens_code action: "skeleton" (默认) code, language?, maxDepth?, filePath?, sessionId? 从源代码生成 AST 骨架(若文件处于焦点内则返回完整代码)
context_lens_code action: "focus" paths: string[], sessionId? 设置当前会话的焦点路径列表
context_lens_code action: "get_focus" sessionId? 获取当前会话的焦点状态
context_lens_code action: "clear_focus" sessionId? 清空当前会话的焦点路径
context_lens_log N/A text (或 log), mode?, maxLines?, auto?, command? 压缩测试或构建日志,保留错误、堆栈及总结信息

⚙️ 配置项

在 DSH 设置中心 (plugins.row.config / plugins.item) 中配置:

配置项 类型 默认值 描述
compressionMode string 'balanced' 日志压缩模式 (raw, balanced, aggressive)
astSkeletonMaxDepth number 3 AST 骨架最大嵌套深度
autoCompressThreshold number 4000 自动压缩触发字符阈值(设为 0 禁用)

📄 授权协议

MIT © GooDAnDReaDY

内容来自项目 README(GitHub)↗

链接

同类插件

查看整个分类 →

社区评论

评论公开保存在 GitHub Discussions。加载评论会连接 GitHub 和 Giscus;发表内容需要 GitHub 账号。