DeepSeek Harness 插件

dsh-code-reuse-firewall

Pre-write reuse firewall for DeepSeek Harness: before the agent writes a new helper/service, surface the existing implementations that already cover that intent. Deterministic retrieval (no LLM)(英文原文)

跳到安装方式

来源信息

GitHub 仓库
keyiadiannao/dsh-code-reuse-firewall
最近更新
2026年8月16日
分类
自动化与任务
GitHub stars
0
载体类型
plugin
目录证据
上游声明已找到 dsh.bundle
证据路径
package.json#dsh.bundle
核对版本
0.1.0-rc.8
上游核对日期
2026-08-20

该证据由上游目录提供。本站没有安装、运行或安全审核这个插件。

安装

默认先复制一段 Prompt,让 Agent 读 GitHub 仓库和源码;需要自己装时再切到命令。

复制这段 Prompt,发给 DSH、Codex 或其他 Agent,让它先读 GitHub 仓库和源码。

请先不要安装或执行任何命令。阅读这个插件的 GitHub 仓库、README 和关键源码,然后用清楚、直接的方式回答以下问题,帮助我判断它是否适合我的需求:

1. 这个插件是什么,解决什么问题;
2. 适合哪些用户和典型使用场景;
3. 安装后如何使用,并给出一个最小使用示例;
4. 有哪些已知限制,以及隐私、安全、兼容性或维护风险;
5. 给出“推荐 / 有条件推荐 / 不推荐”的明确建议和理由。

请区分仓库明确说明、根据源码推断和未知信息。证据不足时请明确说明,不要猜测或照抄 README。

GitHub:https://github.com/keyiadiannao/dsh-code-reuse-firewall
插件名:dsh-code-reuse-firewall
作者:keyiadiannao

检查来源文件

安装前先看这个插件目录里的 README 和其他文件。

文件资源管理器3 个文件
README.md来源说明 · 只读预览

dsh-code-reuse-firewall

Pre-write reuse firewall for DeepSeek Harness — for PYTHON repositories. Before the agent writes a new helper / service / manager, reuse_check deterministically surfaces the existing Python implementations that already cover that intent, so the agent reuses or extracts instead of duplicating.

Why

Static checkers only catch what looks wrong. The expensive failure mode in AI-maintained codebases is the opposite: two implementations of the same capability drift apart silently, because nothing looked broken when the second copy was written. The fix is to intervene before the second copy exists — surface the overlap while the new code is still a plan, not a file.

The retrieval is deterministic and LLM-free (callable-name, docstring lexical, and string-literal channels with IDF-weighted query coverage, stdlib Python only), backed by the Auto_code_audit capability channel. It was validated on an unfamiliar mid-size project (arrow-py): a 1s scan surfaced nine near-identical locale _format_timeframe methods, four describe twins, and api.get vs ArrowFactory.get near-duplicates with zero noise in the dead-code / hardcoded / style categories.

Requirements

(its capability_retrieval.py is the retrieval engine).

  • A Python 3.10+ interpreter (default python).

Install

dsh plugin add github:keyiadiannao/dsh-code-reuse-firewall#master

Then configure the audit checkout and interpreter in your profile:

- id: dsh-code-reuse-firewall
  config:
    auditRoot: 'D:/path/to/Auto_code_audit'   # required
    pythonPath: 'python'                       # default
    maxK: 5                                    # top-K candidates
    minScore: 0.1                              # score floor
    timeoutMs: 30000                           # child-process cap

Usage

The agent calls reuse_check before writing new code:

> 调用 reuse_check:我要实现「从 JSON 配置读取并支持环境变量覆盖」,根目录是 > D:/project/src。看看有没有现成的实现可以复用。 > > (call reuse_check: I'm about to implement "load a JSON config with > environment-variable overrides", root D:/project/src. Is there an existing > implementation to reuse?)

The tool returns top candidates with paths, scores, and per-channel evidence:

Existing implementations overlapping "load a JSON config with env overrides":
  [0.72] config.py:load_config  (src/config.py) (name=0.72 doc=0.10 literal=0.00)
  [0.51] util.py:ConfigLoader.load  (src/util.py) (name=0.51 doc=0.00 literal=0.00)

Hash-locked candidates are flagged. When an existing implementation lives in a file pinned by a frozen-JSON provenance manifest (e.g. current_dependency_files / files_sha256 in frozen_results/ or configs/), the tool marks it 🔒 LOCKED with the locking manifests. Editing such a file invalidates the frozen results that reference it — the correct reuse is to import it, never to copy-and-modify its implementation. Derived run-output trees (outputs/, reports/, logs/, runs/, cache/) are treated as snapshots, not edit constraints, so scripts that merely appear in run metadata are not falsely flagged.

  [0.32] lib/protocol.py:_split_hash_payload  (lib/protocol.py) (name=0.32) 🔒 LOCKED by configs/generation_b_training_compatibility.json

⚠ 1 candidate(s) are in hash-locked files: REUSE by import, do not copy-and-modify their implementation (editing invalidates frozen results).

Advisory evidence, not a verdict. The agent decides whether to reuse, extract a shared component, or write new code — and must never delete or rewrite anything based on retrieval alone (the same ground rule as Auto_code_audit: deterministic output is evidence, not a defect verdict).

Signal-strength caveat (honest limits)

A natural-language --describe query has NO code yet, so the retrieval engine's strongest signals — normalized AST structure, call-name overlap, string-literal overlap — cannot fire. The pre-write channel relies on the weaker name/docstring-lexical/string-literal channels. In practice:

  • A well-named existing function whose docstring matches your description WILL

be surfaced (verified: load_config for "load a JSON config with env overrides").

  • Describe in English keywords a function name/docstring would use

(load json config settings environment env override). Chinese-only descriptions match poorly against English code — the engine tokenizes CJK into bigrams with no Chinese↔English mapping.

  • Structurally-similar-but-differently-named code (the strongest reuse signal)

is only found AFTER code exists, via the engine's --file / --base modes — which are not yet exposed through this plugin.

  • Each candidate carries per-channel evidence (name / docstring / string-literal

scores) in the tool result, so the agent can judge WHY something matched instead of trusting one blended score.

So treat reuse_check as a low-signal pre-write hint, not a full reuse audit. The high-signal modes are roadmap items below.

Configuration

KeyDefaultDescription
auditRoot— (required)Auto_code_audit checkout containing capability_retrieval.py
pythonPathpythonPython interpreter for the retrieval script
maxK5Top-K candidates per query
minScore0.3Score floor (aligned with the engine's default; measured hits sit at 0.33+, lower scores are mostly noise)
timeoutMs30000Child-process timeout — retrieval never hangs a turn

The plugin parses the retrieval JSON with a schema_version === 1 contract check: if Auto_code_audit ever changes its output schema, reuse_check fails loudly with "out of contract" instead of silently mis-parsing.

Development

pnpm run build        # tsdown: host + client bundle
pnpm run typecheck    # tsc --noEmit
pnpm test             # vitest

Roadmap

  • tools/pre-execute guard: run a reuse check automatically before write-tool

calls when a reuse_check was not already performed (dsh-tool-git style).

  • --file / --base modes (check a new/changed file or diff against a git ref)

exposed through the tool.

License

MIT