dshbase

插件目录 / Developer / dsh-refactor-insight

dsh-refactor-insight

已验证 · 实测可装 duyanta123

✓ 持续维护 基于 1 个官方 DSH 包

查看 GitHub ↗ ← 返回插件目录

0Stars
0Forks
0未关闭 issue
—语言
2026-08-22最近推送
跨平台平台

功能简介

Turn codebase smells into an executable, priority-ordered refactoring plan (file-length / deep-nesting / TODO-density).

✅
我们的评价
可用 — 实测通过,早期项目

Turn codebase smells into an executable, priority-ordered refactoring plan (file-length / deep-nesting / TODO-density). 实测能干净安装、正常启动。早期项目,但功能可用。

「已验证」表示我们的自动化 CI 在干净 profile 里实际执行了 dsh plugin add 并启动成功——仅此而已。功能描述与版本兼容性均为作者声明。这不是安全审计,也不代表对第三方代码的背书。

README

dsh-refactor-insight

License: MIT
DeepSeek Harness
version

DSH 技能插件:把代码库的坏味道转成带定位、优先级和依赖顺序的可执行重构计划——结构健康体检,而非 diff 审查。

Turn codebase smells into an executable, priority-ordered refactoring plan.

能力(v0)

六条确定性坏味道规则(阈值均可参数覆盖,零依赖启发式):

  • 超长文件(默认 > 400 行)
  • 深嵌套(默认最大缩进 / 花括号深度 > 5)
  • TODO/FIXME 密度(噪音指标,输出每千行计数)
  • 长函数(Python 缩进块 / JS-TS 花括号配对 / Go 函数声明,函数体 > 80 行)
  • 上帝对象(类方法数 > 10 或类体行数 > 300 / Go 接收者方法数)
  • 高耦合模块(复用 arch-profile --deps 输出,按入度/出度识别 hub 模块 + Tarjan 环检测)
  • 只输出计划、不自动改代码;高风险重构项由 LLM 标注、须人工确认。

脚本只给硬事实(确定性扫描),严重度 / 成本 / 建议动作由 LLM 精修真误报后标注推断。

快速开始

在 DSH 中使用

  1. 安装插件:dsh plugin --profile web add github:duyanta123/dsh-refactor-insight
    • 发布 v0.1.0 tag 后,可改为 github:duyanta123/dsh-refactor-insight#v0.1.0 锁定版本。
  2. 使用:对 Agent 说「用 refactor-insight 体检 /path/to/repo」
  3. 输出:按 docs/refactor-plan-template.md 生成 REFACTOR-PLAN.md。

只跑诊断 CLI(零依赖,不经过 DSH 也能跑)

# 六条规则诊断
node scripts/refactor-smell.mjs <repo_path>

# 复用 arch-profile 的依赖输出做高耦合/环检测
node scripts/arch-profile.mjs <repo_path> --deps > deps.json
node scripts/refactor-smell.mjs <repo_path> --deps-json deps.json

主要参数:--max-lines、--max-func-lines、--max-nesting、--max-methods、--max-class-lines、--max-coupling、--max-depth、--include-dirs、--exclude-dirs。

示例输出(节选):

{
  "language": "javascript/typescript",
  "smells": [
    {
      "rule": "god-object",
      "type": "god_object",
      "path": "src/lib/GodService.js",
      "name": "GodService",
      "methods": 12,
      "threshold": 10,
      "severity": 2,
      "cost": "M"
    }
  ]
}

目录结构

dsh-refactor-insight/
├── package.json                  # npm 包 + dsh.bundle.patch
├── cordis.patch.yml              # DSH bundle patch
├── plugin/index.js               # ESM 入口,注册 skills/ 为技能根
├── skills/refactor-runbook/SKILL.md  # 技能 frontmatter + 阶段执行 runbook
├── docs/refactor-plan-template.md    # 输出报告骨架
├── scripts/arch-profile.mjs      # 复用:probe/scan/deps/entry(零依赖)
├── scripts/refactor-smell.mjs    # 坏味道诊断器(六条规则,--deps-json 复用 arch-profile deps)
└── test/                         # node --test 测试 + fixtures

本地开发

  1. profile 的 package.json 加 "dsh-refactor-insight": "file:<本地路径>/dsh-refactor-insight",bundles 加 "dsh-refactor-insight"。
  2. 测试:npm test
  3. 打包检查:npm pack --dry-run

输出

  • REFACTOR-PLAN.md:结构化重构计划(按 docs/refactor-plan-template.md 骨架)

安装

🧩 让 Agent 自动装(推荐)

装一次目录插件,之后本站所有插件都能让 DeepSeek Harness 自动找、自动装:

dsh plugin add dshbase-catalog

然后对 agent 说「帮我装 dsh-refactor-insight」,它会在目录里找到并自动安装。文档:dshbase-catalog · 已验证场景包。

该插件是 GitHub 源码(未发 npm)——直接从仓库装:

Web profile:

dsh plugin --profile web add github:duyanta123/dsh-refactor-insight

Headless(CLI)profile:

dsh plugin --profile headless add github:duyanta123/dsh-refactor-insight

实测报告

验证通过:从 GitHub 源码完成 L1 安装 + L2 加载 + L3 运行(dsh 0.1.0-rc.6)。

安全:尚未扫描——我们的每日静态扫描将很快覆盖它。

分享徽章

Developer 里更多

浏览全部 7819 个插件 →