dislop 0.8.1 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.cursor-plugin/plugin.json +1 -1
- package/README.md +21 -1
- package/README.zh-CN.md +21 -1
- package/bin/dislop.mjs +52 -8
- package/gemini-extension.json +1 -1
- package/package.json +3 -1
- package/packs/core/pack.json +8 -4
- package/plugin.json +1 -1
- package/server.json +1 -1
- package/skills/deslop-docs/SKILL.md +19 -0
- package/skills/deslop-slides-docx/SKILL.md +19 -0
- package/skills/deslop-verify/SKILL.md +21 -0
- package/skills/deslop-web-ui/SKILL.md +19 -0
- package/skills/dislop/SKILL.md +1 -1
- package/src/core.mjs +22 -5
- package/src/dislop/review-picker.vim +114 -0
- package/src/review-apply.mjs +151 -0
- package/src/review-client.mjs +10 -1
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
},
|
|
7
7
|
"metadata": {
|
|
8
8
|
"description": "Official dislop plugin marketplace: pure-doc Agent Skill and Official Cloud MCP.",
|
|
9
|
-
"version": "0.8.
|
|
9
|
+
"version": "0.8.3"
|
|
10
10
|
},
|
|
11
11
|
"plugins": [
|
|
12
12
|
{
|
|
13
13
|
"name": "dislop",
|
|
14
14
|
"source": "./",
|
|
15
15
|
"description": "Cutting AI slop is real productivity. Linter for AI Slop with vetted rules (7 packs, 53 rules, 65 patterns) across pure-doc Skill, offline CLI, and Official Cloud MCP.",
|
|
16
|
-
"version": "0.8.
|
|
16
|
+
"version": "0.8.3",
|
|
17
17
|
"author": {
|
|
18
18
|
"name": "dislop-ai",
|
|
19
19
|
"url": "https://dislop.com"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dislop",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "Cutting AI slop is real productivity. Linter for AI Slop with vetted rules (7 packs, 53 rules, 65 patterns) across pure-doc Skill, offline CLI, and Official Cloud MCP.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "dislop-ai",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dislop",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "Cutting AI slop is real productivity. Linter for AI Slop with vetted rules (7 packs, 53 rules, 65 patterns) across pure-doc Skill, offline CLI, and Official Cloud MCP.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "dislop-ai",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dislop",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "Cutting AI slop is real productivity. Linter for AI Slop with vetted rules (7 packs, 53 rules, 65 patterns) across pure-doc Skill, offline CLI, and Official Cloud MCP.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "dislop-ai",
|
package/README.md
CHANGED
|
@@ -51,6 +51,14 @@ For hosted review, sign in at [dislop.com](https://dislop.com) or connect Offici
|
|
|
51
51
|
|
|
52
52
|
## Quick start
|
|
53
53
|
|
|
54
|
+
### One-line handoff to your Agent (evaluate, install, and run first check)
|
|
55
|
+
|
|
56
|
+
Paste this sentence into your coding or office agent (Claude Code, Codex, Cursor, OpenClaw, etc.) so it reads `https://dislop.com/llms.txt`, selects the right surface for your environment, configures it, and checks existing files:
|
|
57
|
+
|
|
58
|
+
```text
|
|
59
|
+
Read https://dislop.com/llms.txt, evaluate which dislop setup fits my environment and project (Skill, offline CLI, or Cloud MCP), install and configure it, and run a first check on our files.
|
|
60
|
+
```
|
|
61
|
+
|
|
54
62
|
### Node.js 20+ (npm, zero dependencies, all 7 packs bundled offline)
|
|
55
63
|
|
|
56
64
|
```bash
|
|
@@ -88,6 +96,18 @@ pip install dislop && dislop check .
|
|
|
88
96
|
<img src="./assets/demos/cli-check-en-v2.gif" alt="dislop CLI offline check failing with exit code 1 on draft and passing with exit code 0 after cleanup" width="840">
|
|
89
97
|
</p>
|
|
90
98
|
|
|
99
|
+
### Apply review suggestions
|
|
100
|
+
|
|
101
|
+
Open the Vim picker for a local draft, or save a JSON review and apply selected edits later.
|
|
102
|
+
|
|
103
|
+
```sh
|
|
104
|
+
dislop review draft.md --offline --interactive-apply
|
|
105
|
+
dislop review draft.md --offline --json > review.json
|
|
106
|
+
dislop apply --review-file review.json --source-file draft.md --include 2,5
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Use the `edit.id` values in your report. To apply every available edit except one, use `--all --exclude 3`. In Vim, move with `j`/`k` or the arrow keys, accept with `y`, reject with `n`, and press Enter to write your choices. Press `q` to discard them. Items that need a source or a writer’s judgment appear as advice. Batch apply runs without Vim. Both commands apply edits to supported UTF-8 text files, including Markdown and HTML. If the file has changed since review, generate a fresh report.
|
|
110
|
+
|
|
91
111
|
## AI artifacts vs. style warnings
|
|
92
112
|
|
|
93
113
|
Auto-rewriters often trade one AI cliché for another or flatten your voice into a generic template. Flat banned-word lists also cause false alarms on ordinary nouns (`Delve` debugger, `wool tapestry`).
|
|
@@ -142,7 +162,7 @@ Beyond the CLI, this repository compiles into a full reference library at `dislo
|
|
|
142
162
|
| Surface | One-liner or 1-click install | What you get |
|
|
143
163
|
|---|---|---|
|
|
144
164
|
| **Any AI chat** | Paste: `Read https://dislop.com/llms.txt and apply its anti-slop rules and checks before delivering my next draft.` | Zero install; reads the `~2.4 KB` index, task guides (`/tasks/*.md`), or atomic rule cards (`/rules/<id>.md`) |
|
|
145
|
-
| **Agent Skill (75+ hosts)** | `npx skills add dislop-ai/dislop` | Installs pure-Markdown [skills/dislop/SKILL.md](./skills/dislop/SKILL.md)
|
|
165
|
+
| **Agent Skill (75+ hosts)** | `npx skills add dislop-ai/dislop` | Installs pure-Markdown [skills/dislop/SKILL.md](./skills/dislop/SKILL.md) (`+` 4 task-focused skills: [deslop-docs](./skills/deslop-docs/SKILL.md), [deslop-slides-docx](./skills/deslop-slides-docx/SKILL.md), [deslop-web-ui](./skills/deslop-web-ui/SKILL.md), [deslop-verify](./skills/deslop-verify/SKILL.md); `0` scripts, `0` network calls) |
|
|
146
166
|
| **Claude Code Plugin** | `/plugin marketplace add dislop-ai/dislop` then `/plugin install dislop@dislop-ai` | Bundles pure-doc Skill + Official Cloud MCP connection (`~130` always-on tokens) |
|
|
147
167
|
| **OpenAI Codex Plugin** | `codex plugin marketplace add dislop-ai/dislop` then `codex plugin add dislop@dislop-ai` | Ships native UI card metadata ([openai.yaml](./skills/dislop/agents/openai.yaml)) and `$dislop` trigger |
|
|
148
168
|
| **Gemini CLI Extension** | `gemini extensions install https://github.com/dislop-ai/dislop` | Connects Official Cloud MCP `https://dislop.com/mcp` via [gemini-extension.json](./gemini-extension.json) |
|
package/README.zh-CN.md
CHANGED
|
@@ -48,6 +48,14 @@ Markdown、纯文本、HTML/CSS/JSX/SVG、图片(`.png`/`.jpg`/`.webp`/`.gif`
|
|
|
48
48
|
|
|
49
49
|
## 上手
|
|
50
50
|
|
|
51
|
+
### 一句话交给你的 Agent(评估、安装并试跑)
|
|
52
|
+
|
|
53
|
+
把下面这句话直接发给你的 Agent(Claude Code、Codex、Cursor、OpenClaw 等),它会读取 `https://dislop.com/llms.txt` 并根据当前环境完成接入和首轮检查:
|
|
54
|
+
|
|
55
|
+
```text
|
|
56
|
+
请阅读 https://dislop.com/llms.txt,结合我当前的环境与项目内容评估最合适的 dislop 接入方式(Skill、本地 CLI 或远程 MCP),完成安装配置并拿现有文件试跑一次。
|
|
57
|
+
```
|
|
58
|
+
|
|
51
59
|
### Node.js 20+(npm,零外部依赖,内置全部 7 套规则包)
|
|
52
60
|
|
|
53
61
|
```bash
|
|
@@ -85,6 +93,18 @@ pip install dislop && dislop check . --lang zh
|
|
|
85
93
|
<img src="./assets/demos/cli-check-zh-v2.gif" alt="dislop CLI 本地离线检查:原稿退出码 1 与清理后退出码 0" width="840">
|
|
86
94
|
</p>
|
|
87
95
|
|
|
96
|
+
### 逐条采用审校建议
|
|
97
|
+
|
|
98
|
+
可以在终端里用 Vim 查看原句和改写,也可以先保存审校结果,再按编号修改原文件。
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
dislop review draft.md --offline --interactive-apply
|
|
102
|
+
dislop review draft.md --offline --json > review.json
|
|
103
|
+
dislop apply --review-file review.json --source-file draft.md --include 2,5
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
编号取自报告中的 `edit.id`。要采用除第 3 条以外的所有可执行修改,用 `--all --exclude 3`。在 Vim 中按 `j`、`k` 或方向键切换,按 `y` 采纳,按 `n` 跳过。回车一次写入已选修改,按 `q` 放弃本次选择。需要补充来源或由作者判断的建议可在界面中查阅。批量修改无需安装 Vim。两种方式都适用于 Markdown、HTML 等受支持的 UTF-8 文本文件。原文有改动时,请重新生成审校报告。
|
|
107
|
+
|
|
88
108
|
## AI 残留硬伤和套话提醒分开查
|
|
89
109
|
|
|
90
110
|
很多自动“去 AI 味”改写工具容易把旧套话换成另一种腔调,或者把你的语气全洗成同一种模版。单纯用黑名单也有毛病,容易误伤正常句子(比如「抓手机拍照」「北京大学、清华大学、复旦大学」)。
|
|
@@ -139,7 +159,7 @@ Node.js 版(`bin/dislop.mjs`)和 Python 版(`src/dislop/`)都零外部
|
|
|
139
159
|
| 接入环境 | 一行命令或一键唤起 | 说明 |
|
|
140
160
|
|---|---|---|
|
|
141
161
|
| **任意联网 AI 对话** | 发一句:`先读 https://dislop.com/llms.txt,按里面的规矩和检查方法把接下来这份稿子过一遍。` | 免安装,直接读约 `2.4 KB` 索引、任务卡(`/tasks/*.md`)或单条规则页(`/rules/<id>.md`) |
|
|
142
|
-
| **跨宿主 Agent Skill** | `npx skills add dislop-ai/dislop` | 安装纯 Markdown
|
|
162
|
+
| **跨宿主 Agent Skill** | `npx skills add dislop-ai/dislop` | 安装纯 Markdown 主技能 [skills/dislop/SKILL.md](./skills/dislop/SKILL.md) 及 4 项场景子技能([deslop-docs](./skills/deslop-docs/SKILL.md)、[deslop-slides-docx](./skills/deslop-slides-docx/SKILL.md)、[deslop-web-ui](./skills/deslop-web-ui/SKILL.md)、[deslop-verify](./skills/deslop-verify/SKILL.md),无脚本、零联网) |
|
|
143
163
|
| **Claude Code 插件** | `/plugin marketplace add dislop-ai/dislop` 后执行 `/plugin install dislop@dislop-ai` | 一键装好纯文档 Skill 与官方远程 MCP 连接(常驻上下文仅约 `130` tokens) |
|
|
144
164
|
| **OpenAI Codex 插件** | `codex plugin marketplace add dislop-ai/dislop` 后执行 `codex plugin add dislop@dislop-ai` | 附带 [openai.yaml](./skills/dislop/agents/openai.yaml) 原生应用卡片与 `$dislop` 快捷指令 |
|
|
145
165
|
| **Gemini CLI 扩展** | `gemini extensions install https://github.com/dislop-ai/dislop` | 基于根目录 [gemini-extension.json](./gemini-extension.json) 直连官方远程 MCP `https://dislop.com/mcp` |
|
package/bin/dislop.mjs
CHANGED
|
@@ -50,6 +50,7 @@ import {
|
|
|
50
50
|
removeInstalledModel,
|
|
51
51
|
runLocalDeslop,
|
|
52
52
|
} from "../src/local-model.mjs";
|
|
53
|
+
import { applyReview, prepareEdits, requirePicker } from "../src/review-apply.mjs";
|
|
53
54
|
import { parseImageBuffer, parsePdfBuffer, readZipXmlEntries } from "../src/binary-node.mjs";
|
|
54
55
|
import {
|
|
55
56
|
resolveProviderConfig,
|
|
@@ -1120,8 +1121,18 @@ const COMMAND_SPECS = {
|
|
|
1120
1121
|
summary: "Create starter .dislop.json config and ensure .dislop.local.json is gitignored.",
|
|
1121
1122
|
examples: ["dislop init"],
|
|
1122
1123
|
},
|
|
1124
|
+
apply: {
|
|
1125
|
+
bools: ["all", "help"],
|
|
1126
|
+
strings: ["review-file", "source-file", "include", "exclude"],
|
|
1127
|
+
optionalStrings: [],
|
|
1128
|
+
shortBools: { h: "help" },
|
|
1129
|
+
shortStrings: {},
|
|
1130
|
+
usage: "dislop apply --review-file REPORT --source-file FILE (--include IDS | --all [--exclude IDS])",
|
|
1131
|
+
summary: "Apply selected exact edits from a saved JSON review.",
|
|
1132
|
+
examples: ["dislop apply --review-file review.json --source-file draft.md --include 2,5"],
|
|
1133
|
+
},
|
|
1123
1134
|
review: {
|
|
1124
|
-
bools: ["offline", "compact", "dry-run", "print-prompt", "yes", "include-notes", "include-hidden", "json", "help", "version"],
|
|
1135
|
+
bools: ["interactive-apply", "offline", "compact", "dry-run", "print-prompt", "yes", "include-notes", "include-hidden", "json", "help", "version"],
|
|
1125
1136
|
strings: ["endpoint", "api-key-env", "provider", "model", "base-url", "pack", "register", "format", "lang", "fail-on", "timeout", "max-chunks", "stdin-filename", "config"],
|
|
1126
1137
|
optionalStrings: [],
|
|
1127
1138
|
shortBools: { y: "yes", h: "help", v: "version" },
|
|
@@ -1129,7 +1140,7 @@ const COMMAND_SPECS = {
|
|
|
1129
1140
|
usage:
|
|
1130
1141
|
"dislop review [file | -] [--offline | --endpoint <url> | --provider openai|gemini|openrouter|compatible|local]\n" +
|
|
1131
1142
|
" [--model <id>] [--base-url <url>] [--pack <id|auto>] [--register <id|auto>]\n" +
|
|
1132
|
-
" [--dry-run] [--print-prompt] [--yes] [--format text|json|agent] [--lang en|zh]",
|
|
1143
|
+
" [--interactive-apply] [--dry-run] [--print-prompt] [--yes] [--format text|json|agent] [--lang en|zh]",
|
|
1133
1144
|
summary: "Multi-layer editorial review (offline rubric preflight or explicit opt-in BYOK LLM review).",
|
|
1134
1145
|
examples: [
|
|
1135
1146
|
"dislop review draft.md --offline --lang zh",
|
|
@@ -3559,7 +3570,7 @@ function findingsToReviewIssues(findings, lang = "en") {
|
|
|
3559
3570
|
const action = strategy === "delete" ? "edit" : strategy === "need-source" ? "ask" : "rewrite";
|
|
3560
3571
|
const why = (f.message?.[lang] || f.message?.en || f.ruleId || "").trim();
|
|
3561
3572
|
const guidance = (f.deletionTest?.[lang] || f.deletionTest?.en || why).trim();
|
|
3562
|
-
|
|
3573
|
+
const issue = {
|
|
3563
3574
|
source: f.source || "rule",
|
|
3564
3575
|
ruleId: f.ruleId,
|
|
3565
3576
|
ticLayer: mapFindingToTicLayer(f),
|
|
@@ -3576,6 +3587,10 @@ function findingsToReviewIssues(findings, lang = "en") {
|
|
|
3576
3587
|
? { question: guidance }
|
|
3577
3588
|
: { instruction: guidance }),
|
|
3578
3589
|
};
|
|
3590
|
+
if (action === "edit" && f.span && f.span.end - f.span.start === codePointLength(issue.quote)) {
|
|
3591
|
+
issue.edit = { start: f.span.start, before: issue.quote, after: "" };
|
|
3592
|
+
}
|
|
3593
|
+
return issue;
|
|
3579
3594
|
});
|
|
3580
3595
|
}
|
|
3581
3596
|
|
|
@@ -3591,7 +3606,8 @@ function groundByokLlmIssues(rawIssues, sourceText, lineStarts) {
|
|
|
3591
3606
|
if (idx === -1) continue;
|
|
3592
3607
|
let action = ["edit", "replace", "delete", "rewrite", "ask"].includes(iss.action) ? iss.action : "rewrite";
|
|
3593
3608
|
if (action === "replace" || action === "delete") action = "edit";
|
|
3594
|
-
|
|
3609
|
+
if (action === "edit" && iss.action !== "delete" && typeof iss.replacement !== "string") action = "rewrite";
|
|
3610
|
+
const rep = action === "edit" && iss.action !== "delete" ? iss.replacement : "";
|
|
3595
3611
|
if (action === "edit" || iss.replacement) {
|
|
3596
3612
|
let introducedSlop = false;
|
|
3597
3613
|
const qLower = q.toLowerCase();
|
|
@@ -3623,9 +3639,9 @@ function groundByokLlmIssues(rawIssues, sourceText, lineStarts) {
|
|
|
3623
3639
|
let lo = 0; let hi = lineStarts.length - 1;
|
|
3624
3640
|
while (lo <= hi) { const mid = (lo + hi) >> 1; if (lineStarts[mid] <= idx) lo = mid + 1; else hi = mid - 1; }
|
|
3625
3641
|
const li = Math.max(0, hi);
|
|
3626
|
-
return { line: li + 1, col:
|
|
3642
|
+
return { line: li + 1, col: codePointLength(src.slice(lineStarts[li], idx)) + 1 };
|
|
3627
3643
|
})() : { line: 1, col: 1 };
|
|
3628
|
-
|
|
3644
|
+
const issue = {
|
|
3629
3645
|
source: "byok-llm",
|
|
3630
3646
|
ruleId: null,
|
|
3631
3647
|
...(VALID_TIC_LAYERS.has(iss.ticLayer) ? { ticLayer: iss.ticLayer } : {}),
|
|
@@ -3641,7 +3657,11 @@ function groundByokLlmIssues(rawIssues, sourceText, lineStarts) {
|
|
|
3641
3657
|
: action === "ask"
|
|
3642
3658
|
? { question: String(iss.question || finalInstruction).trim() }
|
|
3643
3659
|
: { instruction: finalInstruction }),
|
|
3644
|
-
}
|
|
3660
|
+
};
|
|
3661
|
+
if (action === "edit" && idx === src.lastIndexOf(q)) {
|
|
3662
|
+
issue.edit = { start: codePointLength(src.slice(0, idx)), before: q, after: rep };
|
|
3663
|
+
}
|
|
3664
|
+
out.push(issue);
|
|
3645
3665
|
if (out.length >= 16) break;
|
|
3646
3666
|
}
|
|
3647
3667
|
return out;
|
|
@@ -3831,6 +3851,8 @@ async function runRubricReview(flags, positional, packs) {
|
|
|
3831
3851
|
summary,
|
|
3832
3852
|
issues,
|
|
3833
3853
|
};
|
|
3854
|
+
prepareEdits(out, text, target);
|
|
3855
|
+
if (flags["interactive-apply"]) return applyReview(out, target, flags, true);
|
|
3834
3856
|
|
|
3835
3857
|
if (format === "json") {
|
|
3836
3858
|
console.log(JSON.stringify(out, null, 2));
|
|
@@ -4279,6 +4301,8 @@ async function runProviderReview(flags, positional, packs) {
|
|
|
4279
4301
|
rejected,
|
|
4280
4302
|
usage: usageSummary,
|
|
4281
4303
|
};
|
|
4304
|
+
prepareEdits(report, rawText, target);
|
|
4305
|
+
if (flags["interactive-apply"]) return applyReview(report, target, flags, true);
|
|
4282
4306
|
|
|
4283
4307
|
if (format === "json") {
|
|
4284
4308
|
console.log(JSON.stringify(report, null, 2));
|
|
@@ -4315,6 +4339,10 @@ async function runReview(args, packs) {
|
|
|
4315
4339
|
printSubcommandHelp("review");
|
|
4316
4340
|
return;
|
|
4317
4341
|
}
|
|
4342
|
+
if (flags["interactive-apply"]) {
|
|
4343
|
+
requirePicker(positional[0] || "-", positional.length === 1 && !flags.json && (!flags.format || flags.format === "text") &&
|
|
4344
|
+
!flags["dry-run"] && !flags["print-prompt"]);
|
|
4345
|
+
}
|
|
4318
4346
|
if (flags.offline || flags.endpoint || flags["api-key-env"]) {
|
|
4319
4347
|
return await runRubricReview(flags, positional, packs);
|
|
4320
4348
|
}
|
|
@@ -4467,6 +4495,7 @@ Browse rules & style:
|
|
|
4467
4495
|
|
|
4468
4496
|
Agent & review:
|
|
4469
4497
|
review [file | -] Multi-layer review (--offline | --endpoint <url> | --provider openai|gemini|local)
|
|
4498
|
+
apply Apply review edits with --review-file and --source-file
|
|
4470
4499
|
--mcp Run local stdio MCP server (7 offline tools)
|
|
4471
4500
|
resources Show bundled packs, static agent links, and Official Cloud MCP
|
|
4472
4501
|
|
|
@@ -4509,7 +4538,22 @@ async function main() {
|
|
|
4509
4538
|
const rest = argv.slice(1);
|
|
4510
4539
|
if (cmd === "check") return runCheck(rest, packs);
|
|
4511
4540
|
if (cmd === "verify") return runVerify(rest, packs);
|
|
4512
|
-
if (cmd === "review"
|
|
4541
|
+
if (cmd === "review" || cmd === "apply") {
|
|
4542
|
+
try {
|
|
4543
|
+
if (cmd === "review") return await runReview(rest, packs);
|
|
4544
|
+
const { flags, positional } = parseFlags(rest, "apply");
|
|
4545
|
+
if (flags.help) return printSubcommandHelp("apply");
|
|
4546
|
+
if (!flags["review-file"] || !flags["source-file"] || positional.length) {
|
|
4547
|
+
throw Error("specify --review-file and --source-file");
|
|
4548
|
+
}
|
|
4549
|
+
const report = JSON.parse(fs.readFileSync(flags["review-file"], "utf8"));
|
|
4550
|
+
return applyReview(report, flags["source-file"], flags);
|
|
4551
|
+
} catch (error) {
|
|
4552
|
+
console.error(`dislop ${cmd}: ${error.message}`);
|
|
4553
|
+
process.exitCode = 2;
|
|
4554
|
+
return;
|
|
4555
|
+
}
|
|
4556
|
+
}
|
|
4513
4557
|
if (cmd === "voice") return runVoice(rest);
|
|
4514
4558
|
if (cmd === "doctor") return await runDoctor(rest, packs);
|
|
4515
4559
|
if (cmd === "model") return await runModel(rest, packs, "model");
|
package/gemini-extension.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dislop",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "Cutting AI slop is real productivity. Linter for AI Slop with vetted rules (7 packs, 53 rules, 65 patterns) across pure-doc Skill, offline CLI, and Official Cloud MCP.",
|
|
5
5
|
"mcpServers": {
|
|
6
6
|
"dislop": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dislop",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "Cutting AI slop is real productivity. Linter for AI Slop in docs, web UI, and slides — Skill, Plugin, CLI & MCP.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://dislop.com",
|
|
@@ -64,6 +64,8 @@
|
|
|
64
64
|
"bin/",
|
|
65
65
|
"src/core.mjs",
|
|
66
66
|
"src/review-client.mjs",
|
|
67
|
+
"src/review-apply.mjs",
|
|
68
|
+
"src/dislop/review-picker.vim",
|
|
67
69
|
"src/pattern-engine.mjs",
|
|
68
70
|
"src/pocket-model.mjs",
|
|
69
71
|
"src/local-model.mjs",
|
package/packs/core/pack.json
CHANGED
|
@@ -84,8 +84,8 @@
|
|
|
84
84
|
"zones": ["prose", "ui-text"],
|
|
85
85
|
"modalities": ["markdown", "text", "html", "jsx", "docx", "pptx", "pdf"],
|
|
86
86
|
"patterns": [
|
|
87
|
-
"(?:^|\\n)\\s*(?:Certainly|Sure|Absolutely|Of course|Happy to help|Glad to help)[!,.]?\\s+(?:[Hh]ere(?:'s|
|
|
88
|
-
"(?:^|\\n)\\s*Here
|
|
87
|
+
"(?:^|\\n)\\s*(?:Certainly|Sure|Absolutely|Of course|Happy to help|Glad to help)[!,.]?\\s+(?:[Hh]ere(?:'s|(?:\\s+it)?\\s+is|\\s+are)|[Bb]elow is)\\b",
|
|
88
|
+
"(?:^|\\n)\\s*Here(?:'s|\\s+is|\\s+are)\\s+(?:a|an|the|your)\\s+(?:revised|updated|polished|cleaned[- ]up|rewritten)\\s+",
|
|
89
89
|
"(?:^|\\n|[.!?]\\s+)\\s*As an AI(?:\\s+(?:language model|assistant))?(?:\\s*,|\\s+(?:I|we|my|here)\\b|\\s*$)",
|
|
90
90
|
"\\bAs an AI (?:language model|assistant)\\b",
|
|
91
91
|
"\\bAs an AI\\s*,\\s*(?:I|we|my)\\b",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"\\bFeel free to (?:reach out|let me know|ask) if you (?:need|have) (?:anything|any (?:other |further )?questions)[!.]?",
|
|
94
94
|
"(?:^|\\n)\\s*(?:好的|当然可以|没问题)[,,!!]?\\s*(?:以下|下面)是",
|
|
95
95
|
"(?:^|\\n)\\s*以下是为您(?:整理|撰写|润色|生成|修改)的",
|
|
96
|
-
"(
|
|
96
|
+
"(?:希望(?:这|以上内容)对(?:你|您)有(?:所)?帮助|如果(?:你|您)(?:还有|需要)(?:任何|其他)?(?:问题|帮助)[,,]?请随时告诉我|如需(?:进一步)?(?:调整|修改)[,,]?请随时(?:告诉我|告知))[!!。.]?",
|
|
97
97
|
"作为一个?\\s*AI(?:\\s*语言模型|\\s*助手)?",
|
|
98
98
|
"\\[oaicite:\\d+\\]",
|
|
99
99
|
"contentReference\\[oaicite:\\d+\\]",
|
|
@@ -129,10 +129,14 @@
|
|
|
129
129
|
"以下是为您整理的会议纪要:周四发布。",
|
|
130
130
|
"Here is the revised launch note: deploys at 14:00 UTC.",
|
|
131
131
|
"作为一个 AI 助手,我建议先做灰度验证。",
|
|
132
|
-
"As an AI, I cannot verify live deployment pricing."
|
|
132
|
+
"As an AI, I cannot verify live deployment pricing.",
|
|
133
|
+
"Certainly! Here it is: Exports finish in up to 12 minutes.",
|
|
134
|
+
"Here's a polished version of your release note: deploys at 14:00 UTC.",
|
|
135
|
+
"希望以上内容对您有所帮助,如需调整请随时告诉我。"
|
|
133
136
|
],
|
|
134
137
|
"clean": [
|
|
135
138
|
"Sure enough, the cache warmed within 40 seconds.",
|
|
139
|
+
"Here is the architecture diagram for service B.",
|
|
136
140
|
"Q2 churn dropped from 4.1% to 3.4%.",
|
|
137
141
|
"会议纪要:周三上线。",
|
|
138
142
|
"以下是本周进展:接口延迟降到 120ms。",
|
package/plugin.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
|
|
3
3
|
"name": "dislop",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.3",
|
|
5
5
|
"description": "Cutting AI slop is real productivity. Linter for AI Slop with vetted rules (7 packs, 53 rules, 65 patterns) across pure-doc Skill, offline CLI, and Official Cloud MCP.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "dislop-ai",
|
package/server.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "io.github.dislop-ai/dislop",
|
|
4
4
|
"title": "dislop",
|
|
5
5
|
"description": "Cutting AI slop is real productivity. Linter for AI Slop in docs, web UI & slides (Cloud MCP).",
|
|
6
|
-
"version": "0.8.
|
|
6
|
+
"version": "0.8.3",
|
|
7
7
|
"websiteUrl": "https://dislop.com",
|
|
8
8
|
"repository": {
|
|
9
9
|
"url": "https://github.com/dislop-ai/dislop",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: deslop-docs
|
|
3
|
+
description: Audit Markdown docs, READMEs, RFCs, and release notes for AI chat wrappers, clichés, and vague filler using dislop offline rules.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# deslop-docs
|
|
7
|
+
|
|
8
|
+
Use when drafting, cleaning, or checking Markdown documentation, technical RFCs, postmortems, READMEs, release notes, or short briefs.
|
|
9
|
+
|
|
10
|
+
## Workflow
|
|
11
|
+
|
|
12
|
+
1. Run an offline deterministic check before rewriting:
|
|
13
|
+
```bash
|
|
14
|
+
npx --yes dislop check <path> --pack auto --deep --compact --json
|
|
15
|
+
```
|
|
16
|
+
2. Remove `error` artifacts first (stray chatbot greetings, citations like `[oaicite:N]`, unfilled placeholders).
|
|
17
|
+
3. Rewrite flagged `warning` clichés and 2nd-order negation slogans (`"Not X, but Y"`) into plain specifics. Keep every original number, unit, date, and qualifier intact.
|
|
18
|
+
4. Do not invent causes, metrics, or examples absent from the draft.
|
|
19
|
+
5. Re-run `npx --yes dislop check <path> --fail-on warning` until hard errors and clichés clear.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: deslop-slides-docx
|
|
3
|
+
description: Check Word (.docx) and PowerPoint (.pptx) files offline for unrendered markdown, chat leftovers, dense slide walls, and empty process titles.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# deslop-slides-docx
|
|
7
|
+
|
|
8
|
+
Use when preparing, inspecting, or cleaning `.docx`, `.pptx`, or PDF slide decks before sharing.
|
|
9
|
+
|
|
10
|
+
## Workflow
|
|
11
|
+
|
|
12
|
+
1. Scan the Office document offline without uploading files:
|
|
13
|
+
```bash
|
|
14
|
+
npx --yes dislop check <deck.pptx-or-doc.docx> --compact --json
|
|
15
|
+
```
|
|
16
|
+
2. Fix OOXML `error` findings first: unrendered `**bold**` or `` `code` `` markup inside text runs, stray AI chat openers, and unfilled bracket placeholders.
|
|
17
|
+
3. Trim slide copy density when `deck-and-ui` or `executive-deck` flags text walls, `normText` shrink-to-fit overflow, empty process titles, or identical consecutive slide layouts.
|
|
18
|
+
4. Keep every metric, date, currency figure, and boundary qualifier exact while shortening sentences.
|
|
19
|
+
5. Re-run `npx --yes dislop check <file>` before exporting or sending.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: deslop-verify
|
|
3
|
+
description: Verify LLM-revised drafts after using Humanizer or stop-slop to catch lost metrics, dropped qualifiers, and 2nd-order slogan drift.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# deslop-verify
|
|
7
|
+
|
|
8
|
+
Use right after running a style rewrite prompt or external humanizer skill on any important draft.
|
|
9
|
+
|
|
10
|
+
## Workflow
|
|
11
|
+
|
|
12
|
+
1. Check the revised file for leaked AI artifacts, `Not X, but Y` 2nd-order slogans, or leftover filler:
|
|
13
|
+
```bash
|
|
14
|
+
npx --yes dislop check <revised-file> --pack auto --deep --compact --json
|
|
15
|
+
```
|
|
16
|
+
2. Verify against git HEAD or the original source file so no numbers, dates, units, URLs, or risk qualifiers (`up to`, `projected`, `only if`) were dropped or altered:
|
|
17
|
+
```bash
|
|
18
|
+
npx --yes dislop verify --git HEAD <revised-file> --strict
|
|
19
|
+
```
|
|
20
|
+
3. If the check catches new AI slogans (`negation-pivot-frame`), swallowed bounds (`up to 12 minutes` -> `5 minutes`), or stiff register drift, restore the exact source numbers and rewrite only the offending phrase.
|
|
21
|
+
4. Re-run both commands until exit code is `0`.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: deslop-web-ui
|
|
3
|
+
description: Inspect AI-generated HTML, CSS, JSX, and SVG pages offline for dead placeholder links, fake disabled buttons, pill soup, and default gradients.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# deslop-web-ui
|
|
7
|
+
|
|
8
|
+
Use when reviewing or cleaning generated frontend components, landing pages, dashboards, or SVGs.
|
|
9
|
+
|
|
10
|
+
## Workflow
|
|
11
|
+
|
|
12
|
+
1. Run the offline structural and UI check:
|
|
13
|
+
```bash
|
|
14
|
+
npx --yes dislop check <ui-dir-or-file> --pack deck-and-ui --compact --json
|
|
15
|
+
```
|
|
16
|
+
2. Eliminate `error` UI bugs first: `<a href="#">` dead links, unimplemented placeholder buttons, `TODO` labels, and `AI-Powered` prompt-echo badges.
|
|
17
|
+
3. Simplify flagged AI layout tics (`warning`): purple-pink neon gradients, pill-badge walls, 3-level nested card frames, and templated eyebrow numbers (`01 / ...`).
|
|
18
|
+
4. Replace banned placeholder copy with concrete product details already in scope; do not fabricate stats or customer logos.
|
|
19
|
+
5. Re-run `npx --yes dislop check <ui-dir-or-file> --fail-on warning` before committing.
|
package/skills/dislop/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: dislop
|
|
3
|
-
version: 0.8.
|
|
3
|
+
version: 0.8.3
|
|
4
4
|
description: "Use when drafting or revising text a person will read: README, docs, PR descriptions, release notes, RFCs, postmortems, CLI help/errors, emails, essays, web pages and UI copy (HTML/CSS/JSX), or Word and PowerPoint files. Removes AI-sounding phrasing, chatbot leftovers, placeholders, and template layouts without changing facts. Skip code logic, tests, refactors, commit messages, and configs with no reader-facing text."
|
|
5
5
|
---
|
|
6
6
|
|
package/src/core.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Shared identically by Node CLI, Node MCP server, and Browser Workbench (`site/`).
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
export const ENGINE_VERSION = "0.8.
|
|
6
|
+
export const ENGINE_VERSION = "0.8.3";
|
|
7
7
|
|
|
8
8
|
export const SEVERITY_RANK = {
|
|
9
9
|
info: 1,
|
|
@@ -4564,7 +4564,7 @@ export function queryCatalog(entries, filters = {}) {
|
|
|
4564
4564
|
const FACT_QUALIFIER_PATTERNS = [
|
|
4565
4565
|
{ group: "min_inc", re: /^(?:no\s+less\s+than|no\s+fewer\s+than|at\s+least|minimum\s+of|>=|≥)\s*/i },
|
|
4566
4566
|
{ group: "min_inc", re: /^(?:不低于|不少于|不小于|不得低于|不得少于|至少|最少|最低|起码|下限(?:为)?)\s*/ },
|
|
4567
|
-
{ group: "max_inc", re: /^(?:no\s+more\s+than|up\s+to|at\s+most|within|max(?:imum)?(?:\s+of)?|<=|≤)\s*/i },
|
|
4567
|
+
{ group: "max_inc", re: /^(?:no\s+more\s+than|up\s+to|at\s+most|within|inside(?:\s+of)?|max(?:imum)?(?:\s+of)?|<=|≤)\s*/i },
|
|
4568
4568
|
{ group: "max_inc", re: /^(?:不超过|不高于|不大于|不多于|不得超过|不得高于|最多|至多|最高|以内|上限(?:为)?)\s*/ },
|
|
4569
4569
|
{ group: "max_lt", re: /^(?:under|below|less\s+than|fewer\s+than|<)\s*/i },
|
|
4570
4570
|
{ group: "max_lt", re: /^(?:低于|小于|少于|不到)\s*/ },
|
|
@@ -4656,7 +4656,7 @@ function canonicalizeNumericToken(token) {
|
|
|
4656
4656
|
curr = rest[0] === "¥" ? "cny" : rest[0];
|
|
4657
4657
|
rest = rest.slice(1).trim();
|
|
4658
4658
|
}
|
|
4659
|
-
const nm = rest.match(/^(\d+(?:\.\d+)?)\s*(.*)$/);
|
|
4659
|
+
const nm = rest.match(/^(\d+(?:\.\d+)?)[\s-]*(.*)$/);
|
|
4660
4660
|
if (!nm) return `${sign}${curr}${rest.toLowerCase()}`;
|
|
4661
4661
|
const numPart = nm[1];
|
|
4662
4662
|
const rawUnit = nm[2].trim();
|
|
@@ -4977,8 +4977,8 @@ export function extractProtectedFacts(text, { modality = "markdown", keepMode =
|
|
|
4977
4977
|
// 3c. Arabic numbers, units, versions, and bounding qualifiers in visible prose
|
|
4978
4978
|
cleanScan = maskOccupied();
|
|
4979
4979
|
const numRe = keepMode
|
|
4980
|
-
? /(?<![A-Za-z0-9_])(?:v\d+(?:\.\d+){1,3}(?![A-Za-z0-9_.])|\d+(?:\.\d+){2,3}(?![A-Za-z0-9_.])|Q[1-4](?![A-Za-z0-9_])|P(?:50|90|95|99)(?![A-Za-z0-9_])|(?:(?<![A-Za-z0-9_.-])[+-])?[$€¥£]\s?(?:\d{1,3}(?:,\d{3})+|\d+)(?:\.\d+)?(?:\s?[kKmMbB](?![A-Za-z0-9_])|万元|亿元|万|亿)?|(?:(?<![A-Za-z0-9_.-])[+-])?(?:\d{1,3}(?:,\d{3})+|\d+)(?:\.\d+)?(?:(?:x|×)(?![A-Za-z0-9_])
|
|
4981
|
-
: /(?<![A-Za-z0-9_])(?:v\d+(?:\.\d+){1,3}(?![A-Za-z0-9_.])|\d+(?:\.\d+){2,3}(?![A-Za-z0-9_.])|Q[1-4](?![A-Za-z0-9_])|P(?:50|90|95|99)(?![A-Za-z0-9_])|(?:(?<![A-Za-z0-9_.-])[+-])?[$€¥£]\s?(?:\d{1,3}(?:,\d{3})+|\d+)(?:\.\d+)?(?:\s?[kKmMbB](?![A-Za-z0-9_])|万|亿)?|(?:(?<![A-Za-z0-9_.-])[+-])?(?:\d{1,3}(?:,\d{3})+|\d+)(?:\.\d+)?(
|
|
4980
|
+
? /(?<![A-Za-z0-9_])(?:v\d+(?:\.\d+){1,3}(?![A-Za-z0-9_.])|\d+(?:\.\d+){2,3}(?![A-Za-z0-9_.])|Q[1-4](?![A-Za-z0-9_])|P(?:50|90|95|99)(?![A-Za-z0-9_])|(?:(?<![A-Za-z0-9_.-])[+-])?[$€¥£]\s?(?:\d{1,3}(?:,\d{3})+|\d+)(?:\.\d+)?(?:\s?[kKmMbB](?![A-Za-z0-9_])|万元|亿元|万|亿)?|(?:(?<![A-Za-z0-9_.-])[+-])?(?:\d{1,3}(?:,\d{3})+|\d+)(?:\.\d+)?(?:(?:x|×)(?![A-Za-z0-9_])|[\s-]?(?:milliseconds?|ms|microseconds?|us|µs|minutes?|mins?|seconds?|secs?|hours?|hrs?|days?|weeks?|months?|years?|KB|MB|GB|TB|PB|QPS|TPS|RPS|fps|px|rows?|items?|files?)(?![A-Za-z0-9_])|\s?(?:%|requests?\/s|req\/s|s(?![A-Za-z0-9_])|毫秒|微秒|秒钟|分钟|小时|个月|万元|亿元|万美元|美元|欧元|日元|千瓦时|倍|秒|天|年|万|亿|元|次|个|条|项|份|页|行|人|家|位|名|台|套|批|种|轮|层|步|篇|章|节))?)/g
|
|
4981
|
+
: /(?<![A-Za-z0-9_])(?:v\d+(?:\.\d+){1,3}(?![A-Za-z0-9_.])|\d+(?:\.\d+){2,3}(?![A-Za-z0-9_.])|Q[1-4](?![A-Za-z0-9_])|P(?:50|90|95|99)(?![A-Za-z0-9_])|(?:(?<![A-Za-z0-9_.-])[+-])?[$€¥£]\s?(?:\d{1,3}(?:,\d{3})+|\d+)(?:\.\d+)?(?:\s?[kKmMbB](?![A-Za-z0-9_])|万|亿)?|(?:(?<![A-Za-z0-9_.-])[+-])?(?:\d{1,3}(?:,\d{3})+|\d+)(?:\.\d+)?(?:[\s-]?(?:milliseconds?|ms|minutes?|mins?|seconds?|secs?|hours?|hrs?|days?|months?|years?|KB|MB|GB|TB|QPS|TPS|RPS|fps|px|rows?)(?![A-Za-z0-9_])|\s?(?:%|s(?![A-Za-z0-9_])|个月|倍|秒|分钟|小时|天|年|万|亿|元|美元|次|个|条|项|份|页|行|人|家|位|名|台|套|批|种|轮|层|步|篇|章|节))?)/g;
|
|
4982
4982
|
|
|
4983
4983
|
while ((m = numRe.exec(cleanScan)) !== null) {
|
|
4984
4984
|
const numStart = m.index;
|
|
@@ -5067,6 +5067,23 @@ export function verifyRevision(beforeText, afterText, { modality = "markdown", a
|
|
|
5067
5067
|
continue;
|
|
5068
5068
|
}
|
|
5069
5069
|
|
|
5070
|
+
const dupPreserved = preserved.find(
|
|
5071
|
+
(p) =>
|
|
5072
|
+
(isNum ? p.kind === "number" || p.kind === "qualified-number" : p.kind === bf.kind) &&
|
|
5073
|
+
p.canonical === bf.canonical &&
|
|
5074
|
+
(p.qualifier || null) === (bf.qualifier || null)
|
|
5075
|
+
);
|
|
5076
|
+
if (dupPreserved) {
|
|
5077
|
+
preserved.push({
|
|
5078
|
+
before: bf.raw,
|
|
5079
|
+
after: dupPreserved.after,
|
|
5080
|
+
kind: bf.kind,
|
|
5081
|
+
canonical: bf.canonical,
|
|
5082
|
+
qualifier: bf.qualifier,
|
|
5083
|
+
});
|
|
5084
|
+
continue;
|
|
5085
|
+
}
|
|
5086
|
+
|
|
5070
5087
|
missing.push({
|
|
5071
5088
|
raw: bf.raw,
|
|
5072
5089
|
kind: bf.kind,
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
" Open an isolated scratch buffer. Draft content is data, never Ex commands.
|
|
2
|
+
set encoding=utf-8 nomodeline noswapfile nobackup noundofile
|
|
3
|
+
setlocal buftype=nofile bufhidden=wipe nospell wrap linebreak
|
|
4
|
+
set laststatus=0 noruler noshowmode
|
|
5
|
+
let s:items = json_decode(join(readfile($DISLOP_PICKER_DIR . '/items.json'), "\n"))
|
|
6
|
+
let s:current = 0
|
|
7
|
+
let s:accepted = {}
|
|
8
|
+
let s:rejected = {}
|
|
9
|
+
|
|
10
|
+
highlight DislopTitle term=bold cterm=bold gui=bold
|
|
11
|
+
if &background ==# 'light'
|
|
12
|
+
highlight DislopRemoved term=underline cterm=bold ctermfg=DarkRed guifg=#9c2434 gui=bold
|
|
13
|
+
highlight DislopAdded term=bold cterm=bold ctermfg=DarkGreen guifg=#176438 gui=bold
|
|
14
|
+
highlight DislopLabel term=bold cterm=bold ctermfg=DarkCyan guifg=#225d74 gui=bold
|
|
15
|
+
else
|
|
16
|
+
highlight DislopRemoved term=underline cterm=bold ctermfg=LightRed guifg=#ff9090 gui=bold
|
|
17
|
+
highlight DislopAdded term=bold cterm=bold ctermfg=LightGreen guifg=#91db9a gui=bold
|
|
18
|
+
highlight DislopLabel term=bold cterm=bold ctermfg=LightCyan guifg=#8dd8e8 gui=bold
|
|
19
|
+
endif
|
|
20
|
+
|
|
21
|
+
function! s:Section(lines, label, text) abort
|
|
22
|
+
if empty(a:text) | return | endif
|
|
23
|
+
call add(a:lines, a:label)
|
|
24
|
+
call matchaddpos('DislopLabel', [len(a:lines)])
|
|
25
|
+
call extend(a:lines, split(a:text, '\r\?\n', 1) + [''])
|
|
26
|
+
endfunction
|
|
27
|
+
|
|
28
|
+
function! s:Diff(lines, sign, group, item, text) abort
|
|
29
|
+
let parts = split(a:text, '\r\?\n', 1)
|
|
30
|
+
let positions = []
|
|
31
|
+
for i in range(len(parts))
|
|
32
|
+
let prefix = i == 0 ? a:item.prefix : ''
|
|
33
|
+
let suffix = i == len(parts) - 1 ? a:item.suffix : ''
|
|
34
|
+
call add(a:lines, a:sign . ' ' . prefix . parts[i] . suffix)
|
|
35
|
+
let row = len(a:lines)
|
|
36
|
+
call add(positions, [row, 1, 1])
|
|
37
|
+
if !empty(parts[i])
|
|
38
|
+
" Vim match columns count bytes, including the gutter and any UTF-8 context.
|
|
39
|
+
call add(positions, [row, 3 + strlen(prefix), strlen(parts[i])])
|
|
40
|
+
endif
|
|
41
|
+
endfor
|
|
42
|
+
" Older Vim versions accept at most eight positions per match.
|
|
43
|
+
for i in range(0, len(positions) - 1, 8)
|
|
44
|
+
call matchaddpos(a:group, positions[i : i + 7])
|
|
45
|
+
endfor
|
|
46
|
+
endfunction
|
|
47
|
+
|
|
48
|
+
function! s:Render() abort
|
|
49
|
+
let item = s:items[s:current]
|
|
50
|
+
let id = string(item.id)
|
|
51
|
+
let state = !has_key(item, 'after') ? 'advice' : has_key(s:accepted, id) ? 'accepted' : has_key(s:rejected, id) ? 'rejected' : 'undecided'
|
|
52
|
+
let zh = $DISLOP_PICKER_LANG ==# 'zh'
|
|
53
|
+
if zh
|
|
54
|
+
let labels = {'advice': '建议', 'accepted': '已采纳', 'rejected': '已跳过', 'undecided': '待选择'}
|
|
55
|
+
let title = printf('第 %d / %d 条 [%s] 已采纳 %d 条', item.id, len(s:items), labels[state], len(s:accepted))
|
|
56
|
+
let keys = 'j/k 或方向键:切换 y/n:采纳或跳过 回车:写入已选修改 q:放弃退出'
|
|
57
|
+
else
|
|
58
|
+
let title = printf('Review %d of %d [%s] %d accepted', item.id, len(s:items), state, len(s:accepted))
|
|
59
|
+
let keys = 'j/k or arrows: move y/n: accept/reject Enter: apply accepted q: cancel'
|
|
60
|
+
endif
|
|
61
|
+
call clearmatches()
|
|
62
|
+
let lines = [title, keys, '']
|
|
63
|
+
call matchaddpos('DislopTitle', [[1, 1, stridx(title, ' ')]])
|
|
64
|
+
let groups = {'accepted': 'DislopAdded', 'rejected': 'DislopRemoved', 'undecided': 'DislopTitle', 'advice': 'DislopLabel'}
|
|
65
|
+
let badge = matchstr(title, '\[[^]]*\]')
|
|
66
|
+
call matchaddpos(groups[state], [[1, stridx(title, badge) + 1, strlen(badge)]])
|
|
67
|
+
call s:Section(lines, zh ? '原因' : 'Why', item.why)
|
|
68
|
+
if has_key(item, 'after')
|
|
69
|
+
call s:Diff(lines, '-', 'DislopRemoved', item, item.before)
|
|
70
|
+
call s:Diff(lines, '+', 'DislopAdded', item, item.after)
|
|
71
|
+
else
|
|
72
|
+
call s:Section(lines, zh ? '原文' : 'Original', item.quote)
|
|
73
|
+
call s:Section(lines, zh ? '建议' : 'Advice', item.advice)
|
|
74
|
+
endif
|
|
75
|
+
setlocal modifiable
|
|
76
|
+
silent %delete _
|
|
77
|
+
call setline(1, lines)
|
|
78
|
+
setlocal nomodifiable nomodified
|
|
79
|
+
normal! gg
|
|
80
|
+
endfunction
|
|
81
|
+
|
|
82
|
+
function! s:Move(step) abort
|
|
83
|
+
let s:current = max([0, min([len(s:items)-1, s:current + a:step])])
|
|
84
|
+
call s:Render()
|
|
85
|
+
endfunction
|
|
86
|
+
|
|
87
|
+
function! s:Decide(accept) abort
|
|
88
|
+
let item = s:items[s:current]
|
|
89
|
+
if has_key(item, 'after')
|
|
90
|
+
let id = string(item.id)
|
|
91
|
+
let keep = a:accept ? s:accepted : s:rejected
|
|
92
|
+
let drop = a:accept ? s:rejected : s:accepted
|
|
93
|
+
let keep[id] = item.id
|
|
94
|
+
if has_key(drop, id) | call remove(drop, id) | endif
|
|
95
|
+
endif
|
|
96
|
+
call s:Move(1)
|
|
97
|
+
endfunction
|
|
98
|
+
|
|
99
|
+
function! s:Finish() abort
|
|
100
|
+
if writefile([json_encode(values(s:accepted))], $DISLOP_PICKER_DIR . '/selected') != 0
|
|
101
|
+
cquit
|
|
102
|
+
endif
|
|
103
|
+
qall!
|
|
104
|
+
endfunction
|
|
105
|
+
|
|
106
|
+
nnoremap <silent><buffer> j :call <SID>Move(1)<CR>
|
|
107
|
+
nnoremap <silent><buffer> k :call <SID>Move(-1)<CR>
|
|
108
|
+
nmap <buffer> <Down> j
|
|
109
|
+
nmap <buffer> <Up> k
|
|
110
|
+
nnoremap <silent><buffer> y :call <SID>Decide(1)<CR>
|
|
111
|
+
nnoremap <silent><buffer> n :call <SID>Decide(0)<CR>
|
|
112
|
+
nnoremap <silent><buffer> <CR> :call <SID>Finish()<CR>
|
|
113
|
+
nnoremap <silent><buffer> q :qall!<CR>
|
|
114
|
+
call s:Render()
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { spawnSync } from "node:child_process";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { detectModality, verifyRevision } from "./core.mjs";
|
|
8
|
+
|
|
9
|
+
export function editableFile(file) {
|
|
10
|
+
const modality = detectModality(file);
|
|
11
|
+
return Boolean(modality && !["docx", "pptx", "pdf", "image"].includes(modality));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const digest = (bytes) => crypto.createHash("sha256").update(bytes).digest("hex");
|
|
15
|
+
|
|
16
|
+
// The on-disk format uses Unicode code points in both runtimes.
|
|
17
|
+
export function prepareEdits(report, text, file) {
|
|
18
|
+
const items = report.issues ?? report.findings;
|
|
19
|
+
const chars = Array.from(text);
|
|
20
|
+
const enabled = file !== "-" && editableFile(file) && !text.includes("\0");
|
|
21
|
+
if (enabled) report.sourceSha256 = digest(text);
|
|
22
|
+
for (const [i, item] of items.entries()) {
|
|
23
|
+
const edit = item.edit;
|
|
24
|
+
if (!edit) continue;
|
|
25
|
+
if (enabled && Number.isSafeInteger(edit.start) && edit.start >= 0 &&
|
|
26
|
+
typeof edit.after === "string" && edit.after.isWellFormed() && !edit.after.includes("\0") &&
|
|
27
|
+
edit.before && edit.before !== edit.after &&
|
|
28
|
+
chars.slice(edit.start, edit.start + Array.from(edit.before).length).join("") === edit.before &&
|
|
29
|
+
verifyRevision(edit.before, edit.after).status === "preserved") {
|
|
30
|
+
edit.id = i + 1;
|
|
31
|
+
} else {
|
|
32
|
+
delete item.edit;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function ids(value) {
|
|
38
|
+
if (value === undefined) return new Set();
|
|
39
|
+
if (!/^[1-9]\d*(,[1-9]\d*)*$/.test(value)) throw Error("expected comma-separated positive edit IDs");
|
|
40
|
+
return new Set(value.split(",").map(Number));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function requirePicker(file, compatible) {
|
|
44
|
+
if (!editableFile(file) || !compatible || !process.stdin.isTTY || !process.stdout.isTTY) {
|
|
45
|
+
throw Error("--interactive-apply requires one supported text file, text output, and an interactive terminal");
|
|
46
|
+
}
|
|
47
|
+
if (spawnSync("vim", ["--version"], { stdio: "ignore" }).status !== 0) throw Error("install Vim to use --interactive-apply");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function pick(items, chars, lang) {
|
|
51
|
+
const rows = items.map((item, i) => {
|
|
52
|
+
const edit = item.edit;
|
|
53
|
+
const row = { id: i + 1, why: item.why ?? item.message?.[lang] ?? item.message?.en ?? "", quote: item.quote ?? item.match ?? "",
|
|
54
|
+
advice: item.instruction ?? item.question ?? item.deletionTest?.[lang] ?? item.deletionTest?.en ?? item.replacement ?? "" };
|
|
55
|
+
if (edit) {
|
|
56
|
+
const end = edit.start + Array.from(edit.before).length;
|
|
57
|
+
Object.assign(row, { before: edit.before, after: edit.after,
|
|
58
|
+
prefix: chars.slice(Math.max(0, edit.start - 60), edit.start).join("").split(/\r?\n/).at(-1),
|
|
59
|
+
suffix: chars.slice(end, end + 60).join("").split(/\r?\n/, 1)[0] });
|
|
60
|
+
}
|
|
61
|
+
return row;
|
|
62
|
+
});
|
|
63
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "dislop-review-"));
|
|
64
|
+
try {
|
|
65
|
+
fs.writeFileSync(path.join(dir, "items.json"), JSON.stringify(rows), { mode: 0o600 });
|
|
66
|
+
const script = fileURLToPath(new URL("./dislop/review-picker.vim", import.meta.url));
|
|
67
|
+
const result = spawnSync("vim", ["-Nu", "NONE", "-i", "NONE", "-n", "-X", "--noplugin", "-S", script], {
|
|
68
|
+
stdio: "inherit", env: { ...process.env, DISLOP_PICKER_DIR: dir, DISLOP_PICKER_LANG: lang },
|
|
69
|
+
});
|
|
70
|
+
if (result.error || result.status !== 0) throw Error("Vim review session did not complete");
|
|
71
|
+
const output = path.join(dir, "selected");
|
|
72
|
+
return fs.existsSync(output) ? new Set(JSON.parse(fs.readFileSync(output, "utf8"))) : new Set();
|
|
73
|
+
} finally {
|
|
74
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function applyReview(report, file, flags, interactive = false) {
|
|
79
|
+
if (!editableFile(file)) throw Error("choose a supported UTF-8 source file");
|
|
80
|
+
const items = report?.issues ?? report?.findings;
|
|
81
|
+
if (report?.schema !== "dislop.review/1" || typeof report.sourceSha256 !== "string" || !Array.isArray(items)) {
|
|
82
|
+
throw Error("this report has no file edit data; rerun review on the source file with --json");
|
|
83
|
+
}
|
|
84
|
+
const target = fs.realpathSync(file);
|
|
85
|
+
if (!fs.statSync(target).isFile()) throw Error("source must be a regular file");
|
|
86
|
+
const original = fs.readFileSync(target);
|
|
87
|
+
if (digest(original) !== report.sourceSha256) throw Error("source differs from reviewed file; rerun review");
|
|
88
|
+
const text = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(original);
|
|
89
|
+
if (text.includes("\0")) throw Error("source contains binary data");
|
|
90
|
+
const chars = Array.from(text);
|
|
91
|
+
const edits = new Map();
|
|
92
|
+
for (const [i, item] of items.entries()) {
|
|
93
|
+
if (!item || typeof item !== "object" || Array.isArray(item)) throw Error(`invalid review item #${i + 1}`);
|
|
94
|
+
const edit = item.edit;
|
|
95
|
+
if (edit === undefined) continue;
|
|
96
|
+
if (edit?.id !== i + 1 || !Number.isSafeInteger(edit.start) || edit.start < 0 ||
|
|
97
|
+
typeof edit.before !== "string" || !edit.before || typeof edit.after !== "string" ||
|
|
98
|
+
!edit.after.isWellFormed() || edit.after.includes("\0")) throw Error(`invalid edit #${i + 1}`);
|
|
99
|
+
edits.set(edit.id, edit);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
let selected;
|
|
103
|
+
if (interactive) {
|
|
104
|
+
selected = items.length ? pick(items, chars, flags.lang || "en") : new Set();
|
|
105
|
+
} else {
|
|
106
|
+
if (Boolean(flags.all) === (flags.include !== undefined) || (flags.exclude !== undefined && !flags.all)) {
|
|
107
|
+
throw Error("choose --include IDS or --all [--exclude IDS]");
|
|
108
|
+
}
|
|
109
|
+
selected = flags.all ? new Set(edits.keys()) : ids(flags.include);
|
|
110
|
+
for (const id of ids(flags.exclude)) {
|
|
111
|
+
if (!edits.has(id)) throw Error(`unknown or advisory edit #${id}`);
|
|
112
|
+
selected.delete(id);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const chosen = [...selected].map((id) => {
|
|
116
|
+
if (!edits.has(id)) throw Error(`unknown or advisory edit #${id}`);
|
|
117
|
+
return edits.get(id);
|
|
118
|
+
}).sort((a, b) => a.start - b.start);
|
|
119
|
+
|
|
120
|
+
const pieces = [];
|
|
121
|
+
let cursor = 0;
|
|
122
|
+
for (const edit of chosen) {
|
|
123
|
+
const end = edit.start + Array.from(edit.before).length;
|
|
124
|
+
if (chars.slice(edit.start, end).join("") !== edit.before) throw Error(`source span mismatch for #${edit.id}`);
|
|
125
|
+
if (edit.start < cursor) throw Error(`overlapping edits at #${edit.id}; select one alternative`);
|
|
126
|
+
pieces.push(chars.slice(cursor, edit.start).join(""), edit.after);
|
|
127
|
+
cursor = end;
|
|
128
|
+
}
|
|
129
|
+
if (chosen.length) {
|
|
130
|
+
pieces.push(chars.slice(cursor).join(""));
|
|
131
|
+
// A sibling staging file serializes dislop writers and permits one same-volume rename.
|
|
132
|
+
const stage = path.join(path.dirname(target), "." + path.basename(target) + ".dislop-apply.tmp");
|
|
133
|
+
const fd = fs.openSync(stage, "wx", 0o600);
|
|
134
|
+
let committed = false;
|
|
135
|
+
try {
|
|
136
|
+
try {
|
|
137
|
+
fs.writeFileSync(fd, pieces.join(""));
|
|
138
|
+
fs.fchmodSync(fd, fs.statSync(target).mode & 0o777);
|
|
139
|
+
} finally {
|
|
140
|
+
fs.closeSync(fd);
|
|
141
|
+
}
|
|
142
|
+
if (!original.equals(fs.readFileSync(target))) throw Error("source changed during apply; rerun review");
|
|
143
|
+
fs.renameSync(stage, target);
|
|
144
|
+
committed = true;
|
|
145
|
+
} finally {
|
|
146
|
+
// A successful rename releases the name; a new writer may already own it.
|
|
147
|
+
if (!committed) fs.unlinkSync(stage);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
console.log(flags.lang === "zh" ? `已写入 ${chosen.length} 处修改。` : `Applied ${chosen.length} edit(s).`);
|
|
151
|
+
}
|
package/src/review-client.mjs
CHANGED
|
@@ -354,7 +354,7 @@ export function buildReviewPrompt({
|
|
|
354
354
|
"Do NOT output a full rewrite of the document.",
|
|
355
355
|
langDirective,
|
|
356
356
|
"Return ONLY valid JSON matching this exact schema (no markdown fences):",
|
|
357
|
-
'{"aiFlavorLevel":"low|medium|high","summary":"1-2 sentence plain summary","issues":[{"category":"framing|cliche|structure|evidence|rhythm","severity":"warning|info","quote":"exact verbatim substring from the draft","why":"specific defect explanation","fix":"concrete edit suggestion preserving facts"}]}',
|
|
357
|
+
'{"aiFlavorLevel":"low|medium|high","summary":"1-2 sentence plain summary","issues":[{"category":"framing|cliche|structure|evidence|rhythm","severity":"warning|info","quote":"exact verbatim substring from the draft","why":"specific defect explanation","fix":"concrete edit suggestion preserving facts","replacement":"optional literal replacement in the original language; empty string for intentional deletion; omit when advice requires judgment"}]}',
|
|
358
358
|
].join("\n");
|
|
359
359
|
|
|
360
360
|
const userPrompt = [
|
|
@@ -572,7 +572,16 @@ export function validateAndNormalizeReviewResponse({
|
|
|
572
572
|
const delObj = fix ? { en: fix, zh: fix } : { en: why, zh: why };
|
|
573
573
|
const fp = `${ruleId}:${fnv1aHex(`${ruleId}|${clipMatch.toLowerCase()}|${line}:${col}`)}`;
|
|
574
574
|
|
|
575
|
+
// Normalized quotes are enough for advice. Writes need one exact occurrence in the reviewed chunk.
|
|
576
|
+
const index = chunkText.indexOf(quote);
|
|
577
|
+
const after = item.replacement;
|
|
578
|
+
let edit;
|
|
579
|
+
if (typeof after === "string" && index >= 0 && index === chunkText.lastIndexOf(quote) &&
|
|
580
|
+
safeQuote === quote && scrubSecrets(after, redactSecrets) === after) {
|
|
581
|
+
edit = { start: codepointCount(fullText.slice(0, chunkStartOffset + index)), before: quote, after };
|
|
582
|
+
}
|
|
575
583
|
findings.push({
|
|
584
|
+
...(edit ? { edit } : {}),
|
|
576
585
|
fingerprint: fp,
|
|
577
586
|
ruleId,
|
|
578
587
|
tier: "taste",
|