只读仓库事实扫描内核:为分析型插件提供可复现的仓库探测、文件索引、模块、依赖、入口、符号与 Git 变更等硬事实(CLI + 库接口 + 技能 runbook)。
安装
# GitHub 源码(首次需按提示配置 allowBuilds 构建授权后重试)
dsh plugin --profile web add github:duyanta123/dsh-repo-scanner
装任何插件都等于在你的机器上跑第三方代码,权限和你本人一样大——能读你的文件、用你的凭据、访问网络,工具审批管不到它。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
面向 DeepSeek Harness 分析型插件(arch-doc、dsh-refactor-insight、dsh-change-impact、dsh-test-insight)的统一、可复现、只读的代码库事实扫描内核。
只读:不修改目标仓库,不安装依赖,不执行项目代码。
作为 DSH 插件安装
本包按 DSH bundle 规范打包(package.json 声明 dsh.bundle.patch),安装后自动注册 repo-scanner-runbook 技能:
dsh plugin --profile web add "github:duyanta123/dsh-repo-scanner#main"
安装后重启 dsh --profile web,技能即可被发现;技能只在需要时加载 runbook,扫描本身通过 shell 调用 CLI 完成。上层插件(dsh-change-impact / dsh-test-insight 等)以库形式依赖本包时,经 exports 子路径 dsh-repo-scanner/scanner 引入扫描内核。
快速开始
node bin/repo-scanner.mjs <repo_path> --probe
node bin/repo-scanner.mjs <repo_path> --files
node bin/repo-scanner.mjs <repo_path> --scan
node bin/repo-scanner.mjs <repo_path> --deps
node bin/repo-scanner.mjs <repo_path> --entry
node bin/repo-scanner.mjs <repo_path> --symbols
node bin/repo-scanner.mjs <repo_path> --graphs
node bin/repo-scanner.mjs <repo_path> --git --diff-text-file diff.txt
node bin/repo-scanner.mjs <repo_path> --all --json
库接口:
import { scanRepository } from 'dsh-repo-scanner/scanner';
const report = await scanRepository({
repoPath: '.',
modes: ['probe', 'modules', 'dependencies', 'entries', 'symbols', 'graphs', 'git'],
maxDepth: 3,
cache: true, // 增量扫描缓存
parsers: ['heuristic'], // 可插拔解析器(tree-sitter 为可选依赖)
symbolQuery: { name: 'auth' }, // 符号查询
git: { diffText },
});
事实 API
import {
getChangeImpactFacts, // 变更影响:反向依赖传播 + 受影响模块/符号
getTestInsightFacts, // 测试洞察:测试↔源码映射 + 模块覆盖
getDocSyncFacts, // 文档同步:文档引用 + 过期引用
} from 'dsh-repo-scanner/scanner';
const impact = await getChangeImpactFacts({
repoPath: '.',
git: { statusText }, // 或 diffText / changedFiles
});
输出示例
{
"schema_version": "1.0",
"analysis_schema": { "name": "dsh-analysis-schema", "version": "1.0" },
"tool": { "name": "dsh-repo-scanner", "version": "0.1.0" },
"input": { "repo_path": ".", "resolved_path": "C:/work/app", "options": {} },
"limits": { "max_depth": 3, "max_files": 2000, "max_file_bytes": 256000, "truncated": false, "warnings": [] },
"project": {},
"files": [],
"modules": [],
"dependencies": { "internal": [], "external": [] },
"entry_points": [],
"run_methods": [],
"symbols": [],
"graphs": null,
"risks": [],
"errors": [],
"performance": null,
"git": null
}
完整字段说明见 docs/output-schema.md;扫描规则见 docs/scanning-rules.md。
参数与退出码
| 参数 | 默认 | 说明 |
|---|---|---|
--max-depth N |
3 | 最大目录深度 |
--max-files N |
2000 | 最大文件数 |
--max-file-bytes N |
256000 | 单文件内容读取上限 |
--include-dirs a,b |
空 | 只扫描这些目录 |
--exclude-dirs a,b |
内置默认 | 追加排除目录 |
--language LANG |
空 | 语言过滤 |
--format json|jsonl |
json | 输出格式 |
--hash |
关 | 计算文件 sha256(按原始字节) |
--strict |
关 | 存在错误或警告时非零退出 |
--follow-symlinks |
关 | 跟随符号链接(目标必须在仓库内) |
--cache / --cache-dir DIR |
关 | 增量扫描缓存(只写临时目录) |
--parsers a,b |
heuristic | 符号解析器链(tree-sitter 为可选依赖,缺失自动回退) |
--symbol-name/file/module |
空 | 符号查询过滤 |
--perf-budget-ms N |
60000 | 性能预算(0 关闭;超限写 warning) |
退出码:0 成功;1 存在错误,或 --strict 下存在警告;2 参数错误或仓库路径无效;3 输出失败或契约错误。
安全红线
- 不写入目标仓库;不做 checkout/reset/clean。
- 不安装依赖、不执行目标项目代码或脚本。
- 路径规范化后拒绝越界;默认不跟随符号链接。
- 不 spawn 子进程获取文件或 Git 事实(由可执行安全审计测试保障)。
- 只把能解析到仓库内部的导入归为 internal;动态 import/require 记入
risks。 - 输出对 token/密码/连接串/JWT 自动脱敏。
与 arch-doc / dsh-refactor-insight 的关系
两个插件都有各自的 arch-profile.mjs。本包提取其扫描逻辑,通过 npm dependency 或 CLI 被它们复用。迁移顺序与字段映射见 docs/migration-guide.md。
开发
npm test # 功能测试 + 安全审计测试
npm run check
Node >=18。
链接
同类插件
strukto-ai/mirage#dsh★ 3600
把文件系统与 bash 提供者换成 mirage 虚拟工作区:文件工具与 shell 命令作用于挂载的资源(RAM、S3、Redis、Slack、Gmail、Notion、Postgres)而非宿主磁盘,支持按挂载点设置读/写/执行模式、按命令选择沙箱(进程内 monty、pyodide、quickjs;远程 docker、e2b、daytona),并可在虚拟终端中安装 CLI(git、gh、slack、linear、ntn、gws,或自行注册的程序树)作为命令头词。
hust-open-atom-club/oh-dsh★ 302
社区发行版:TUI、桌面端与 Web UI 统一体验,分层安装、一步到位。
ZSeven-W/dsh-ios★ 275
在 DSH 对话中运行 iOS 模拟器与 USB 连接的真机:21 个 agent 工具,可启动设备、构建运行 Xcode 工程、按无障碍标识 / OCR 文本 / 列表行驱动 UI、读取统一日志并查看进程、backtrace 与内存泄漏,并附带可点按、拖拽、旋转的实时侧边栏画面。
lire1131/dsh-undo-savepoint★ 144
DSH 撤销/回退系统:配置变更自动存档,一键撤销/恢复/回退到任意版本,支持 WebUI 与离线 CLI/GUI 工具(DSH 启动失败也能救)。
Fishquito7/dsh-skill-mcp-panel★ 115
在 DSH Web 设置中管理技能与 MCP 服务器:技能卡片热启停、工作区作用域、分组、批量迁移与拖拽导入,以及 stdio/HTTP MCP 增删改查、连接测试、密钥脱敏,并附带统一 dsh-panel 命令行。
kanneiren/dsh-network-settings★ 108
可视化 DSH 进程在 Windows 或 WSL 上的网络链路(DNS/TCP/TLS/HTTP 分层探测),检测失效的代理配置,并提供带快照回滚的安全修复。
社区评论
评论公开保存在 GitHub Discussions。加载评论会连接 GitHub 和 Giscus;发表内容需要 GitHub 账号。