YJ73 downloadsCompare Markdown drafts inline, restore deleted text, track moved paragraphs, save ideas, and rewrite with Codex CLI or DeepSeek Harness (dsh).
Compare drafts, right in your Obsidian editor.
Refactor Lens shows additions, deletions, and likely paragraph moves between Markdown drafts directly in the editor. Restore a deleted passage, save it for later, or optionally rewrite selected prose with Codex CLI or DeepSeek Harness (dsh). Comparison marks are visual overlays; they do not add diff syntax to your Markdown.
RefactorLens is available in Obsidian Community Plugins and currently supports desktop only.
Move detection is heuristic. Always review its result before treating a paragraph as definitively moved.
AI rewriting is optional. Draft comparison, restoration, and the scratchpad work without a CLI or an API key. Configure credentials in your chosen CLI, not in the plugin. In Settings → Refactor Lens → AI 改写引擎与模型, choose one locally installed CLI:
| Backend | Executable and model | Authentication |
|---|---|---|
| OpenAI Codex CLI | codex. Leave the model ID blank to use Codex's own configuration, or enter a model available to your setup. |
Configure Codex outside Obsidian. Use codex login status to check sign-in. |
| DeepSeek Harness CLI | dsh. Leave the model ID blank to use the Harness headless configuration. When overriding the model, a blank provider ID uses deepseek-official; for that route, deepseek-flash is the DeepSeek-V4.1-Flash model ID. Use a provider and model ID configured in Harness for a custom route. |
The standard headless profile does not reuse GUI sign-in. For the official route, make DEEPSEEK_API_KEY available to the process or configure it in Harness's home .env (normally ~/.dsh/.env, or $DSH_HOME/.env). See headless credentials. |
Leave the executable path blank for auto-detection. If it fails, enter the absolute path to the executable file, rather than its installation folder or an entire shell command. On macOS, command -v codex or command -v dsh can help locate it. A variable exported only in a terminal shell may not be available to Obsidian when launched from the Dock. Refactor Lens starts dsh from a private temporary directory, so a vault-local .env is not used as its working-directory configuration.
Open the header pill menu to see the selected CLI's detection status beside the rewrite assistant. Check CLI (检测 CLI) in plugin settings locates the executable without starting it. A rewrite starts the CLI and checks that it responds. To check Codex sign-in separately, run codex login status in your terminal. If Harness is detected but cannot run, check dsh --version and dsh --profile headless --help; the latter must list both --permission-mode and --approval-policy.
On Windows, run where.exe codex and codex --version in PowerShell. If automatic detection fails, enter the full path to the native codex.exe in plugin settings. The plugin can resolve standard npm installations to their native executable without running the codex.cmd script.
_scratchpad.md beside the current note by default, or use a shared vault-root file with a configurable name.RefactorLens has no telemetry or analytics.
data.json. If you configure absolute local paths, that file can contain those paths; exclude it from untrusted sync or version control when appropriate.1.13.0 or later.In Obsidian, open Settings → Community plugins → Browse, search for Refactor Lens, and select Install and Enable. Use Check for updates in Community plugins to upgrade an existing installation.
For a manual development installation:
Download or clone this repository.
Install dependencies and build the plugin:
npm ci
npm run build
Create this directory inside your vault:
<Vault>/.obsidian/plugins/refactor-lens/
Copy these files into it:
main.js
manifest.json
styles.css
Reload Obsidian and enable Refactor Lens under Settings → Community plugins.
npm ci
npm test
npm run lint
npm run build
The production build generates main.js. The test suite is self-contained and does not require private vault files or Codex credentials.
Release assets from 0.1.1 onward are built by GitHub Actions and receive GitHub artifact attestations. After downloading an asset, verify it with the GitHub CLI:
gh attestation verify main.js -R lacemou/RefactorLens
gh attestation verify manifest.json -R lacemou/RefactorLens
gh attestation verify styles.css -R lacemou/RefactorLens
Please avoid including private note content, credentials, or personal paths in a public issue. Use a minimal reproduction and redact sensitive material.
Refactor Lens(文案透镜):在 Obsidian 编辑器里直接对比稿件。
在同一个编辑器里查看两版 Markdown 稿件的新增、删除和疑似段落搬迁。删掉的文字可以恢复或存入灵感抽屉,也可以选用 Codex CLI 或 DeepSeek Harness(dsh)改写所选正文。比对标记只显示在编辑器里,不会写进 Markdown。
Refactor Lens 已进入 Obsidian Community Plugins,目前仅支持桌面端。
段落搬家采用启发式算法,结果应由用户复核,不能视为绝对判断。
AI 改写是可选功能。稿件比对、文字恢复和灵感抽屉都不需要 CLI 或 API Key。凭据在对应 CLI 里配置,不用填进插件。要使用改写,请到 设置 → Refactor Lens → AI 改写引擎与模型,选择一个本机已安装的 CLI:
| 引擎 | 程序与模型 | 认证 |
|---|---|---|
| OpenAI Codex CLI | 程序为 codex。模型 ID 留空就沿用 Codex 配置,也可填写当前账号或网关支持的模型。 |
在 Obsidian 外完成 Codex 认证,可用 codex login status 检查。 |
| DeepSeek Harness CLI | 程序为 dsh。模型 ID 留空就沿用 Harness headless 配置。若指定模型,提供方 ID 留空会使用 deepseek-official;官方路由的 deepseek-flash 对应 DeepSeek-V4.1-Flash。自定义网关需填在 Harness 中已配置的提供方和模型 ID。 |
标准 headless 配置不会复用图形界面的登录。官方路由可通过进程环境或 Harness 主目录的 .env 提供 DEEPSEEK_API_KEY,通常是 ~/.dsh/.env;自定义主目录则是 $DSH_HOME/.env。详见 headless 认证说明。 |
程序路径可留空自动探测。找不到时,填写可执行文件的绝对路径,不要填安装目录或整条命令。macOS 上可用 command -v codex 或 command -v dsh 查找。只在终端里导出的变量,从 Dock 启动的 Obsidian 不一定能继承。插件会从私有临时目录启动 dsh,所以 Vault 里的 .env 不会作为其工作目录配置使用。
Windows 上可在 PowerShell 运行 where.exe codex 和 codex --version。如果自动探测失败,请在设置里填写原生 codex.exe 的绝对路径。对于标准 npm 安装,插件可以定位原生程序,无需执行 codex.cmd 脚本。
顶部修订透镜药丸的「呼出改写顾问」旁显示所选 CLI 的检测状态。设置里的「检测 CLI」只查找可执行文件,实际改写时才启动 CLI 并检查它是否响应。要查看 Codex 登录状态,请在终端运行 codex login status。如果检测到 Harness 但改写失败,先运行 dsh --version 和 dsh --profile headless --help,确认后者列出了 --permission-mode 和 --approval-policy。
_scratchpad.md;也可改用 Vault 根目录下的共享文件,文件名可配置。RefactorLens 不包含遥测或数据分析。
data.json。若填写绝对路径,该文件可能包含本地路径;必要时请将其排除在不可信的同步或版本控制之外。1.13.0 或更高版本。在 Obsidian 中打开 设置 → 第三方插件 → 浏览,搜索 Refactor Lens,安装后启用。已安装的用户可在第三方插件页面「检查更新」。
如需手动安装开发版本:
下载或克隆本仓库。
安装依赖并构建:
npm ci
npm run build
在 Vault 中创建目录:
<Vault>/.obsidian/plugins/refactor-lens/
将以下文件复制进去:
main.js
manifest.json
styles.css
重新加载 Obsidian,在 设置 → 第三方插件 中启用 Refactor Lens。
npm ci
npm test
npm run lint
npm run build
生产构建会生成 main.js。测试用例完全自包含,不依赖私人 Vault 文件或 Codex 凭据。
从 0.1.1 起,发布产物由 GitHub Actions 构建,并生成 GitHub 产物证明。下载后可使用 GitHub CLI 验证:
gh attestation verify main.js -R lacemou/RefactorLens
gh attestation verify manifest.json -R lacemou/RefactorLens
gh attestation verify styles.css -R lacemou/RefactorLens
公开提交 Issue 时,请勿附上私人文稿、登录凭据或真实本地路径。请使用最小复现材料,并对敏感内容脱敏。