dislop 0.9.0 → 1.0.1
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 +3 -3
- package/.claude-plugin/plugin.json +2 -2
- package/.codex-plugin/plugin.json +7 -8
- package/.cursor-plugin/plugin.json +2 -3
- package/.pre-commit-hooks.yaml +5 -12
- package/PRODUCT.md +19 -57
- package/README.md +360 -252
- package/README.zh-CN.md +390 -240
- package/action.yml +30 -39
- package/bin/dislop-mcp.mjs +3 -4
- package/bin/dislop.mjs +4 -4582
- package/gemini-extension.json +2 -2
- package/llms-install.md +68 -0
- package/package.json +17 -55
- package/packs/common/artifact-qa/pack.json +5 -0
- package/packs/common/artifact-qa/prompts/rules.md +11 -0
- package/packs/common/artifact-qa/scripts/index.mjs +173 -0
- package/packs/common/slide-deck/pack.json +6 -0
- package/packs/common/slide-deck/prompts/rules.md +11 -0
- package/packs/common/slide-deck/scripts/index.mjs +62 -0
- package/packs/common/web-ui/pack.json +6 -0
- package/packs/common/web-ui/prompts/rules.md +11 -0
- package/packs/common/web-ui/scripts/index.mjs +80 -0
- package/packs/en/artifact-qa/pack.json +6 -0
- package/packs/en/artifact-qa/prompts/rules.md +14 -0
- package/packs/en/artifact-qa/scripts/index.mjs +90 -0
- package/packs/en/prose/pack.json +7 -0
- package/packs/en/prose/prompts/rules.md +26 -0
- package/packs/en/prose/scripts/index.mjs +290 -0
- package/packs/en/slide-deck/pack.json +7 -0
- package/packs/en/slide-deck/prompts/rules.md +17 -0
- package/packs/en/slide-deck/scripts/index.mjs +81 -0
- package/packs/en/web-ui/pack.json +7 -0
- package/packs/en/web-ui/prompts/rules.md +20 -0
- package/packs/en/web-ui/scripts/index.mjs +103 -0
- package/packs/zh/artifact-qa/pack.json +6 -0
- package/packs/zh/artifact-qa/prompts/rules.md +14 -0
- package/packs/zh/artifact-qa/scripts/index.mjs +89 -0
- package/packs/zh/prose/pack.json +7 -0
- package/packs/zh/prose/prompts/rules.md +26 -0
- package/packs/zh/prose/scripts/index.mjs +305 -0
- package/packs/zh/slide-deck/pack.json +7 -0
- package/packs/zh/slide-deck/prompts/rules.md +17 -0
- package/packs/zh/slide-deck/scripts/index.mjs +75 -0
- package/packs/zh/web-ui/pack.json +7 -0
- package/packs/zh/web-ui/prompts/rules.md +20 -0
- package/packs/zh/web-ui/scripts/index.mjs +98 -0
- package/plugin.json +5 -6
- package/server.json +8 -2
- package/skills/deslop-docs/SKILL.md +10 -8
- package/skills/deslop-slides-docx/SKILL.md +7 -8
- package/skills/deslop-verify/SKILL.md +7 -8
- package/skills/deslop-web-ui/SKILL.md +7 -8
- package/skills/dislop/SKILL.md +16 -28
- package/skills/dislop/references/essay.md +1 -1
- package/skills/dislop/references/essay.zh-CN.md +1 -1
- package/skills/dislop/references/office.md +1 -1
- package/skills/dislop/references/office.zh-CN.md +1 -1
- package/skills/dislop/references/web-ui.md +1 -1
- package/skills/dislop/references/web-ui.zh-CN.md +1 -1
- package/skills/dislop/references/work-docs.md +1 -1
- package/skills/dislop/references/work-docs.zh-CN.md +1 -1
- package/src/cli-main.mjs +210 -0
- package/src/commands/check-fix.mjs +169 -0
- package/src/commands/doctor.mjs +110 -0
- package/src/commands/init.mjs +49 -0
- package/src/commands/login.mjs +82 -0
- package/src/commands/model.mjs +130 -0
- package/src/commands/packs.mjs +44 -0
- package/src/commands/verify.mjs +133 -0
- package/src/commands/voice.mjs +84 -0
- package/src/kernel/config.mjs +232 -0
- package/src/kernel/document-model.mjs +1412 -0
- package/src/kernel/fact-gate.mjs +615 -0
- package/src/kernel/file-discovery.mjs +139 -0
- package/src/{binary-node.mjs → kernel/ooxml-binary.mjs} +532 -893
- package/src/kernel/pack-loader.mjs +715 -0
- package/src/kernel/patcher.mjs +341 -0
- package/src/kernel/pipeline.mjs +267 -0
- package/src/kernel/prompt-assembler.mjs +307 -0
- package/src/kernel/voice-profile.mjs +177 -0
- package/src/mcp/stdio-server.mjs +372 -0
- package/src/runners/auto-fix.mjs +59 -0
- package/src/runners/interactive-tty.mjs +461 -0
- package/src/runners/reporters.mjs +256 -0
- package/src/runtime/chunker.mjs +87 -0
- package/src/runtime/json-extract.mjs +144 -0
- package/src/runtime/privacy-gate.mjs +97 -0
- package/src/runtime/providers/anthropic.mjs +65 -0
- package/src/runtime/providers/cloud.mjs +136 -0
- package/src/runtime/providers/gemini.mjs +91 -0
- package/src/runtime/providers/local-model.mjs +139 -0
- package/src/runtime/providers/openai-compat.mjs +130 -0
- package/src/runtime/router.mjs +315 -0
- package/src/sdk/index.mjs +137 -0
- package/models/manifest.json +0 -90
- package/models/pocket-slop-v1.json +0 -1
- package/packs/business-brief/pack.json +0 -937
- package/packs/core/pack.json +0 -209
- package/packs/deck-and-ui/pack.json +0 -539
- package/packs/engineering-spec/pack.json +0 -144
- package/packs/executive-deck/pack.json +0 -98
- package/packs/literary-essay/pack.json +0 -344
- package/packs/regulated-comms/pack.json +0 -99
- package/patterns/ai-tic-rubric.json +0 -252
- package/patterns/banks/composite-fusion.json +0 -48
- package/patterns/banks/discourse-rhythm.json +0 -95
- package/patterns/banks/lexical-signals.json +0 -92
- package/patterns/banks/syntactic-frames.json +0 -52
- package/patterns/banks/visual-deck.json +0 -44
- package/patterns/dimensions/artifacts.json +0 -121
- package/patterns/dimensions/discourse.json +0 -438
- package/patterns/dimensions/lexical.json +0 -198
- package/patterns/dimensions/rhythm.json +0 -258
- package/patterns/dimensions/syntactic.json +0 -285
- package/patterns/dimensions/visual-and-deck.json +0 -530
- package/patterns/taxonomy.json +0 -112
- package/src/core.mjs +0 -5497
- package/src/dislop/review-picker.vim +0 -114
- package/src/local-model.mjs +0 -997
- package/src/pattern-engine.mjs +0 -1003
- package/src/pocket-model.mjs +0 -729
- package/src/review-apply.mjs +0 -151
- package/src/review-client.mjs +0 -1073
package/src/review-apply.mjs
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
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
|
-
}
|