dislop 0.9.1 → 1.1.0

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.
Files changed (129) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/.claude-plugin/plugin.json +2 -2
  3. package/.codex-plugin/plugin.json +7 -8
  4. package/.cursor-plugin/plugin.json +2 -3
  5. package/.pre-commit-hooks.yaml +5 -12
  6. package/PRODUCT.md +19 -63
  7. package/README.md +358 -249
  8. package/README.zh-CN.md +391 -237
  9. package/action.yml +30 -39
  10. package/bin/dislop-mcp.mjs +3 -4
  11. package/bin/dislop.mjs +4 -4594
  12. package/gemini-extension.json +2 -2
  13. package/llms-install.md +68 -0
  14. package/package.json +17 -63
  15. package/packs/common/artifact-qa/pack.json +5 -0
  16. package/packs/common/artifact-qa/prompts/rules.md +11 -0
  17. package/packs/common/artifact-qa/scripts/index.mjs +235 -0
  18. package/packs/common/slide-deck/pack.json +6 -0
  19. package/packs/common/slide-deck/prompts/rules.md +11 -0
  20. package/packs/common/slide-deck/scripts/index.mjs +62 -0
  21. package/packs/common/web-ui/pack.json +6 -0
  22. package/packs/common/web-ui/prompts/rules.md +11 -0
  23. package/packs/common/web-ui/scripts/index.mjs +80 -0
  24. package/packs/en/artifact-qa/pack.json +6 -0
  25. package/packs/en/artifact-qa/prompts/rules.md +14 -0
  26. package/packs/en/artifact-qa/scripts/index.mjs +90 -0
  27. package/packs/en/prose/pack.json +7 -0
  28. package/packs/en/prose/prompts/rules.md +26 -0
  29. package/packs/en/prose/scripts/index.mjs +293 -0
  30. package/packs/en/slide-deck/pack.json +7 -0
  31. package/packs/en/slide-deck/prompts/rules.md +17 -0
  32. package/packs/en/slide-deck/scripts/index.mjs +81 -0
  33. package/packs/en/web-ui/pack.json +7 -0
  34. package/packs/en/web-ui/prompts/rules.md +20 -0
  35. package/packs/en/web-ui/scripts/index.mjs +103 -0
  36. package/packs/zh/artifact-qa/pack.json +6 -0
  37. package/packs/zh/artifact-qa/prompts/rules.md +14 -0
  38. package/packs/zh/artifact-qa/scripts/index.mjs +89 -0
  39. package/packs/zh/prose/pack.json +7 -0
  40. package/packs/zh/prose/prompts/rules.md +26 -0
  41. package/packs/zh/prose/scripts/index.mjs +305 -0
  42. package/packs/zh/slide-deck/pack.json +7 -0
  43. package/packs/zh/slide-deck/prompts/rules.md +17 -0
  44. package/packs/zh/slide-deck/scripts/index.mjs +75 -0
  45. package/packs/zh/web-ui/pack.json +7 -0
  46. package/packs/zh/web-ui/prompts/rules.md +20 -0
  47. package/packs/zh/web-ui/scripts/index.mjs +98 -0
  48. package/plugin.json +5 -6
  49. package/server.json +2 -2
  50. package/skills/deslop-docs/SKILL.md +10 -8
  51. package/skills/deslop-slides-docx/SKILL.md +7 -8
  52. package/skills/deslop-verify/SKILL.md +7 -8
  53. package/skills/deslop-web-ui/SKILL.md +7 -8
  54. package/skills/dislop/SKILL.md +16 -28
  55. package/skills/dislop/agents/openai.yaml +1 -1
  56. package/skills/dislop/references/essay.md +6 -6
  57. package/skills/dislop/references/essay.zh-CN.md +6 -6
  58. package/skills/dislop/references/office.md +5 -5
  59. package/skills/dislop/references/office.zh-CN.md +5 -5
  60. package/skills/dislop/references/web-ui.md +4 -4
  61. package/skills/dislop/references/web-ui.zh-CN.md +4 -4
  62. package/skills/dislop/references/work-docs.md +7 -7
  63. package/skills/dislop/references/work-docs.zh-CN.md +7 -7
  64. package/src/cli-main.mjs +292 -0
  65. package/src/commands/check-fix.mjs +324 -0
  66. package/src/commands/doctor.mjs +132 -0
  67. package/src/commands/init.mjs +55 -0
  68. package/src/commands/login.mjs +82 -0
  69. package/src/commands/model.mjs +130 -0
  70. package/src/commands/packs.mjs +81 -0
  71. package/src/commands/verify.mjs +165 -0
  72. package/src/commands/voice.mjs +84 -0
  73. package/src/commands/worklog.mjs +424 -0
  74. package/src/kernel/config.mjs +759 -0
  75. package/src/kernel/document-model.mjs +1432 -0
  76. package/src/kernel/fact-gate.mjs +775 -0
  77. package/src/kernel/file-discovery.mjs +296 -0
  78. package/src/{binary-node.mjs → kernel/ooxml-binary.mjs} +615 -890
  79. package/src/kernel/pack-loader.mjs +801 -0
  80. package/src/kernel/pack-validator.mjs +491 -0
  81. package/src/kernel/patcher.mjs +471 -0
  82. package/src/kernel/pipeline.mjs +530 -0
  83. package/src/kernel/prompt-assembler.mjs +336 -0
  84. package/src/kernel/version.mjs +7 -0
  85. package/src/kernel/voice-profile.mjs +180 -0
  86. package/src/mcp/stdio-server.mjs +442 -0
  87. package/src/runners/auto-fix.mjs +74 -0
  88. package/src/runners/interactive-tty.mjs +488 -0
  89. package/src/runners/reporters.mjs +272 -0
  90. package/src/runtime/chunker.mjs +87 -0
  91. package/src/runtime/json-extract.mjs +144 -0
  92. package/src/runtime/privacy-gate.mjs +97 -0
  93. package/src/runtime/providers/anthropic.mjs +65 -0
  94. package/src/runtime/providers/cloud.mjs +138 -0
  95. package/src/runtime/providers/gemini.mjs +91 -0
  96. package/src/runtime/providers/local-model.mjs +147 -0
  97. package/src/runtime/providers/openai-compat.mjs +130 -0
  98. package/src/runtime/router.mjs +324 -0
  99. package/src/runtime/worklog.mjs +904 -0
  100. package/src/sdk/index.mjs +137 -0
  101. package/models/manifest.json +0 -90
  102. package/models/pocket-slop-v1.json +0 -1
  103. package/packs/business-brief/pack.json +0 -937
  104. package/packs/core/pack.json +0 -209
  105. package/packs/deck-and-ui/pack.json +0 -539
  106. package/packs/engineering-spec/pack.json +0 -144
  107. package/packs/executive-deck/pack.json +0 -98
  108. package/packs/literary-essay/pack.json +0 -344
  109. package/packs/regulated-comms/pack.json +0 -99
  110. package/patterns/ai-tic-rubric.json +0 -252
  111. package/patterns/banks/composite-fusion.json +0 -48
  112. package/patterns/banks/discourse-rhythm.json +0 -95
  113. package/patterns/banks/lexical-signals.json +0 -92
  114. package/patterns/banks/syntactic-frames.json +0 -52
  115. package/patterns/banks/visual-deck.json +0 -44
  116. package/patterns/dimensions/artifacts.json +0 -121
  117. package/patterns/dimensions/discourse.json +0 -438
  118. package/patterns/dimensions/lexical.json +0 -198
  119. package/patterns/dimensions/rhythm.json +0 -258
  120. package/patterns/dimensions/syntactic.json +0 -285
  121. package/patterns/dimensions/visual-and-deck.json +0 -530
  122. package/patterns/taxonomy.json +0 -112
  123. package/src/core.mjs +0 -5497
  124. package/src/dislop/review-picker.vim +0 -114
  125. package/src/local-model.mjs +0 -997
  126. package/src/pattern-engine.mjs +0 -1003
  127. package/src/pocket-model.mjs +0 -729
  128. package/src/review-apply.mjs +0 -151
  129. package/src/review-client.mjs +0 -1073
@@ -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
- }