Skip to main content
M

dsh-ctxfold

mrfeng-rancheng/dsh-ctxfold

Assembles code context as guarded state so long coding sessions cost fewer input tokens, with doctor, ask and status tools and the CLI bundled in the package.

Install

dsh plugin --profile web add github:mrfeng-rancheng/dsh-ctxfold

README

dsh-ctxfold

把 ctxfold 注册为 DeepSeek Harness 的原生工具——装好即自动生效, 不需要让模型自己想起来敲命令。

提供三个工具

工具作用只读
ctxfold_doctor采用前体检:仓库规模、依赖密度、模拟节省、严格可见率损失、建议预算与是否 --strict是
ctxfold_ask为某个问题装配一轮上下文(不调用模型):返回将要发送的 prompt、`### #path::symbolfile:start-end` 出处头、卡片/占位符、token 与免算状态
ctxfold_status记忆条数(fresh/stale)、账本事件计数、预算与 guard 级别是

依赖

不需要单独安装工具。 插件自带 endor/ctxfold-tool.zip,首次调用任一工具时会自动解包到用户 site-packages(纯文件复制,不需要网络、不需要 pip、不受中文路径影响)。想额外得到 ctxfold 命令别名,再 pip install 一次即可,属可选。

依赖(可选)

本机需已安装 ctxfold 命令:

# 工具本体在本包的 03-插件-ctxfold工具 目录(等价于安装该目录)
python -m pip install "<本包路径>/03-插件-ctxfold工具"
ctxfold --help          # 确认可用

安装

Windows 直接双击投稿包根目录的 一键安装.cmd(macOS 一键安装.command,Linux ./一键安装.sh)。 它会自动找 DSH profile、装插件、装工具本体并自检。等价的命令行写法:

cd <本包路径>/04-插件-DSH集成
python install.py --with-tool "<本包路径>/03-插件-ctxfold工具"

它补齐 DSH 认插件需要的四处登记(node_modules 文件、dependencies、dsh.profile.bundles、cordis.patch.yml 的 insert 行), 改前自动备份,已存在的跳过。先看要改什么加 --dry-run;profile 不是 desktop 加 --profile <名字>。

装完完全退出并重开 DSH(刷新页面不算)。

找不到 ctxfold 命令时

插件按三级回退找工具:环境变量 CTXFOLD_BIN → PATH 里的 ctxfold → python -m ctxfold.cli。 都不行才报错,并在报错里列出尝试过的命令。可用环境变量指定:

变量例子用途
CTXFOLD_BINC:/Python312/Scripts/ctxfold.exe直接指向可执行文件
CTXFOLD_PYTHONC:/Python312/python.exe指向解释器,插件自动改用 python -m ctxfold.cli

排障与常见问题见 安装说明.md。

配置(cordis.patch.yml)

- insert:
    - id: dsh-ctxfold
      name: dsh-ctxfold
      config:
        enabled: true
        corpus: ''        # 默认仓库根;留空则用会话工作目录
        budget: 1600      # 单轮证据 token 预算
        strict: false     # true = 可见性优先(成本约 +45%,严格可见率 +31pt)
        timeoutMs: 90000

说明

  • 纯只读 + 本地子进程调用,不联网、不读密钥。
  • 参数以数组传给 execFile,不做字符串拼接,避免命令注入。
  • 若 ctxfold 未安装,工具会返回一条明确的安装提示,而不是报错崩溃。
  • token 数为估算值(代码文本上偏高约 30%),当上界看;省了多少百分比 这类比值不受影响。
  • 关闭插件:把 config.enabled 设为 false。

Related plugins