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.
Files changed (124) 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 -57
  7. package/README.md +360 -252
  8. package/README.zh-CN.md +390 -240
  9. package/action.yml +30 -39
  10. package/bin/dislop-mcp.mjs +3 -4
  11. package/bin/dislop.mjs +4 -4582
  12. package/gemini-extension.json +2 -2
  13. package/llms-install.md +68 -0
  14. package/package.json +17 -55
  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 +173 -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 +290 -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 +8 -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/references/essay.md +1 -1
  56. package/skills/dislop/references/essay.zh-CN.md +1 -1
  57. package/skills/dislop/references/office.md +1 -1
  58. package/skills/dislop/references/office.zh-CN.md +1 -1
  59. package/skills/dislop/references/web-ui.md +1 -1
  60. package/skills/dislop/references/web-ui.zh-CN.md +1 -1
  61. package/skills/dislop/references/work-docs.md +1 -1
  62. package/skills/dislop/references/work-docs.zh-CN.md +1 -1
  63. package/src/cli-main.mjs +210 -0
  64. package/src/commands/check-fix.mjs +169 -0
  65. package/src/commands/doctor.mjs +110 -0
  66. package/src/commands/init.mjs +49 -0
  67. package/src/commands/login.mjs +82 -0
  68. package/src/commands/model.mjs +130 -0
  69. package/src/commands/packs.mjs +44 -0
  70. package/src/commands/verify.mjs +133 -0
  71. package/src/commands/voice.mjs +84 -0
  72. package/src/kernel/config.mjs +232 -0
  73. package/src/kernel/document-model.mjs +1412 -0
  74. package/src/kernel/fact-gate.mjs +615 -0
  75. package/src/kernel/file-discovery.mjs +139 -0
  76. package/src/{binary-node.mjs → kernel/ooxml-binary.mjs} +532 -893
  77. package/src/kernel/pack-loader.mjs +715 -0
  78. package/src/kernel/patcher.mjs +341 -0
  79. package/src/kernel/pipeline.mjs +267 -0
  80. package/src/kernel/prompt-assembler.mjs +307 -0
  81. package/src/kernel/voice-profile.mjs +177 -0
  82. package/src/mcp/stdio-server.mjs +372 -0
  83. package/src/runners/auto-fix.mjs +59 -0
  84. package/src/runners/interactive-tty.mjs +461 -0
  85. package/src/runners/reporters.mjs +256 -0
  86. package/src/runtime/chunker.mjs +87 -0
  87. package/src/runtime/json-extract.mjs +144 -0
  88. package/src/runtime/privacy-gate.mjs +97 -0
  89. package/src/runtime/providers/anthropic.mjs +65 -0
  90. package/src/runtime/providers/cloud.mjs +136 -0
  91. package/src/runtime/providers/gemini.mjs +91 -0
  92. package/src/runtime/providers/local-model.mjs +139 -0
  93. package/src/runtime/providers/openai-compat.mjs +130 -0
  94. package/src/runtime/router.mjs +315 -0
  95. package/src/sdk/index.mjs +137 -0
  96. package/models/manifest.json +0 -90
  97. package/models/pocket-slop-v1.json +0 -1
  98. package/packs/business-brief/pack.json +0 -937
  99. package/packs/core/pack.json +0 -209
  100. package/packs/deck-and-ui/pack.json +0 -539
  101. package/packs/engineering-spec/pack.json +0 -144
  102. package/packs/executive-deck/pack.json +0 -98
  103. package/packs/literary-essay/pack.json +0 -344
  104. package/packs/regulated-comms/pack.json +0 -99
  105. package/patterns/ai-tic-rubric.json +0 -252
  106. package/patterns/banks/composite-fusion.json +0 -48
  107. package/patterns/banks/discourse-rhythm.json +0 -95
  108. package/patterns/banks/lexical-signals.json +0 -92
  109. package/patterns/banks/syntactic-frames.json +0 -52
  110. package/patterns/banks/visual-deck.json +0 -44
  111. package/patterns/dimensions/artifacts.json +0 -121
  112. package/patterns/dimensions/discourse.json +0 -438
  113. package/patterns/dimensions/lexical.json +0 -198
  114. package/patterns/dimensions/rhythm.json +0 -258
  115. package/patterns/dimensions/syntactic.json +0 -285
  116. package/patterns/dimensions/visual-and-deck.json +0 -530
  117. package/patterns/taxonomy.json +0 -112
  118. package/src/core.mjs +0 -5497
  119. package/src/dislop/review-picker.vim +0 -114
  120. package/src/local-model.mjs +0 -997
  121. package/src/pattern-engine.mjs +0 -1003
  122. package/src/pocket-model.mjs +0 -729
  123. package/src/review-apply.mjs +0 -151
  124. package/src/review-client.mjs +0 -1073
@@ -0,0 +1,372 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import crypto from "node:crypto";
5
+ import { resolveLayeredConfig } from "../kernel/config.mjs";
6
+ import { verifyDocumentRevision } from "../kernel/fact-gate.mjs";
7
+ import { listBuiltinPackIds } from "../kernel/pack-loader.mjs";
8
+ import { runDocumentPipeline } from "../kernel/pipeline.mjs";
9
+ import { runAutoFixOnDocumentResult } from "../runners/auto-fix.mjs";
10
+ import { formatAgentReports } from "../runners/reporters.mjs";
11
+ import { resolveExecutionRoute } from "../runtime/router.mjs";
12
+
13
+ const SUPPORTED_MCP_VERSIONS = ["2024-11-05", "2025-03-26", "2025-06-18", "2025-11-25"];
14
+
15
+ export const LOCAL_MCP_TOOLS = [
16
+ {
17
+ name: "dislop_check",
18
+ description:
19
+ "Inspect a file or inline text for objective delivery Defects and non-blocking editorial Suggestions (returns compact agent report + dislop.report/1).",
20
+ annotations: {
21
+ readOnlyHint: true,
22
+ idempotentHint: true,
23
+ destructiveHint: false,
24
+ openWorldHint: false,
25
+ },
26
+ inputSchema: {
27
+ type: "object",
28
+ properties: {
29
+ filePath: { type: "string", description: "Path to local file on disk" },
30
+ text: { type: "string", description: "Inline document text when checking unsaved content" },
31
+ format: {
32
+ type: "string",
33
+ description: "Document format extension when passing inline text (e.g., md, html, jsx)",
34
+ },
35
+ packs: {
36
+ type: "array",
37
+ items: { type: "string" },
38
+ description: "Optional Pack IDs or paths (e.g., ['common/artifact-qa', 'en/prose'])",
39
+ },
40
+ noLlm: { type: "boolean", description: "Run deterministic Script Packs only (default true for fast local MCP checks)" },
41
+ level: { type: "string", enum: ["strong", "moderate", "hint", "all"] },
42
+ },
43
+ },
44
+ },
45
+ {
46
+ name: "dislop_fix_safe",
47
+ description:
48
+ "Atomically apply verified fixSafety === 'safe' edits on a local file and return the unified diff + remaining report.",
49
+ annotations: {
50
+ readOnlyHint: false,
51
+ idempotentHint: true,
52
+ destructiveHint: false,
53
+ openWorldHint: false,
54
+ },
55
+ inputSchema: {
56
+ type: "object",
57
+ required: ["filePath"],
58
+ properties: {
59
+ filePath: { type: "string" },
60
+ dryRun: { type: "boolean" },
61
+ backup: { type: "boolean" },
62
+ packs: { type: "array", items: { type: "string" } },
63
+ },
64
+ },
65
+ },
66
+ {
67
+ name: "dislop_verify",
68
+ description:
69
+ "Verify that a revised draft preserved all numbers, units, URLs, inline code spans, and proper nouns from the original without introducing second-order AI slogans.",
70
+ annotations: {
71
+ readOnlyHint: true,
72
+ idempotentHint: true,
73
+ destructiveHint: false,
74
+ openWorldHint: false,
75
+ },
76
+ inputSchema: {
77
+ type: "object",
78
+ required: ["beforeText", "afterText"],
79
+ properties: {
80
+ beforeText: { type: "string" },
81
+ afterText: { type: "string" },
82
+ },
83
+ },
84
+ },
85
+ {
86
+ name: "dislop_packs",
87
+ description: "List built-in multi-modal and language Packs available in this dislop installation.",
88
+ annotations: {
89
+ readOnlyHint: true,
90
+ idempotentHint: true,
91
+ destructiveHint: false,
92
+ openWorldHint: false,
93
+ },
94
+ inputSchema: {
95
+ type: "object",
96
+ properties: {},
97
+ },
98
+ },
99
+ ];
100
+
101
+ export async function handleMcpJsonRpcRequest(msg, { cwd = process.cwd(), env = process.env } = {}) {
102
+ if (!msg || typeof msg !== "object") {
103
+ return {
104
+ jsonrpc: "2.0",
105
+ id: null,
106
+ error: { code: -32600, message: "Invalid JSON-RPC request" },
107
+ };
108
+ }
109
+
110
+ // Notifications carry no `id` and produce no response frame
111
+ if (msg.id === undefined) {
112
+ return null;
113
+ }
114
+
115
+ const { id, method, params = {} } = msg;
116
+
117
+ try {
118
+ if (method === "initialize") {
119
+ const clientVer = params?.protocolVersion;
120
+ const protocolVersion = SUPPORTED_MCP_VERSIONS.includes(clientVer)
121
+ ? clientVer
122
+ : "2025-03-26";
123
+ return {
124
+ jsonrpc: "2.0",
125
+ id,
126
+ result: {
127
+ protocolVersion,
128
+ serverInfo: {
129
+ name: "dislop",
130
+ version: "1.0.1",
131
+ },
132
+ capabilities: {
133
+ tools: {},
134
+ },
135
+ instructions:
136
+ "Use dislop_check to audit deliverables (Defects vs. non-blocking Suggestions). After revising prose in project context, call dislop_verify to ensure no numbers, units, URLs, code spans, or entities were dropped.",
137
+ },
138
+ };
139
+ }
140
+
141
+ if (method === "ping") {
142
+ return { jsonrpc: "2.0", id, result: {} };
143
+ }
144
+
145
+ if (method === "tools/list") {
146
+ return {
147
+ jsonrpc: "2.0",
148
+ id,
149
+ result: { tools: LOCAL_MCP_TOOLS },
150
+ };
151
+ }
152
+
153
+ if (method === "tools/call") {
154
+ const toolName = params?.name;
155
+ const args = params?.arguments || {};
156
+
157
+ if (toolName === "dislop_packs") {
158
+ const packs = listBuiltinPackIds();
159
+ return {
160
+ jsonrpc: "2.0",
161
+ id,
162
+ result: {
163
+ content: [{ type: "text", text: JSON.stringify({ packs }, null, 2) }],
164
+ structuredContent: { packs },
165
+ },
166
+ };
167
+ }
168
+
169
+ if (toolName === "dislop_verify") {
170
+ const res = verifyDocumentRevision(String(args.beforeText || ""), String(args.afterText || ""));
171
+ return {
172
+ jsonrpc: "2.0",
173
+ id,
174
+ result: {
175
+ content: [{ type: "text", text: JSON.stringify(res, null, 2) }],
176
+ structuredContent: res,
177
+ },
178
+ };
179
+ }
180
+
181
+ if (toolName === "dislop_check") {
182
+ let targetPath = args.filePath ? path.resolve(cwd, String(args.filePath)) : null;
183
+ let tmpFile = null;
184
+
185
+ try {
186
+ if (!targetPath) {
187
+ if (typeof args.text !== "string") {
188
+ throw new Error("Provide either 'filePath' or 'text' to dislop_check.");
189
+ }
190
+ const ext = String(args.format || "md").replace(/^\./, "");
191
+ tmpFile = path.join(
192
+ os.tmpdir(),
193
+ `dislop-mcp-${process.pid}-${crypto.randomBytes(4).toString("hex")}.${ext}`,
194
+ );
195
+ fs.writeFileSync(tmpFile, args.text, "utf8");
196
+ targetPath = tmpFile;
197
+ }
198
+
199
+ const config = resolveLayeredConfig({
200
+ cwd,
201
+ env,
202
+ cliFlags: {
203
+ packs: Array.isArray(args.packs) ? args.packs : null,
204
+ noLlm: args.noLlm !== undefined ? Boolean(args.noLlm) : true,
205
+ level: args.level || "all",
206
+ },
207
+ });
208
+ const route = await resolveExecutionRoute({ config, isTty: false, env });
209
+ const docRes = await runDocumentPipeline({ filePath: targetPath, config, route, cwd });
210
+ if (tmpFile) {
211
+ docRes.report.file = `inline.${args.format || "md"}`;
212
+ }
213
+ const agentText = formatAgentReports([docRes]);
214
+
215
+ return {
216
+ jsonrpc: "2.0",
217
+ id,
218
+ result: {
219
+ content: [{ type: "text", text: agentText }],
220
+ structuredContent: docRes.report,
221
+ },
222
+ };
223
+ } finally {
224
+ if (tmpFile && fs.existsSync(tmpFile)) {
225
+ fs.unlinkSync(tmpFile);
226
+ }
227
+ }
228
+ }
229
+
230
+ if (toolName === "dislop_fix_safe") {
231
+ if (!args.filePath) {
232
+ throw new Error("dislop_fix_safe requires 'filePath'.");
233
+ }
234
+ const targetPath = path.resolve(cwd, String(args.filePath));
235
+ const config = resolveLayeredConfig({
236
+ cwd,
237
+ env,
238
+ cliFlags: {
239
+ packs: Array.isArray(args.packs) ? args.packs : null,
240
+ noLlm: true,
241
+ },
242
+ });
243
+ const route = await resolveExecutionRoute({ config, isTty: false, env });
244
+ const docRes = await runDocumentPipeline({ filePath: targetPath, config, route, cwd });
245
+ const fixRes = runAutoFixOnDocumentResult(docRes, {
246
+ dryRun: Boolean(args.dryRun),
247
+ backup: Boolean(args.backup),
248
+ });
249
+
250
+ return {
251
+ jsonrpc: "2.0",
252
+ id,
253
+ result: {
254
+ content: [
255
+ {
256
+ type: "text",
257
+ text: JSON.stringify(
258
+ {
259
+ appliedCount: fixRes.appliedCount,
260
+ modified: fixRes.modified,
261
+ diff: fixRes.diff,
262
+ report: fixRes.report,
263
+ },
264
+ null,
265
+ 2,
266
+ ),
267
+ },
268
+ ],
269
+ structuredContent: {
270
+ appliedCount: fixRes.appliedCount,
271
+ modified: fixRes.modified,
272
+ report: fixRes.report,
273
+ },
274
+ },
275
+ };
276
+ }
277
+
278
+ return {
279
+ jsonrpc: "2.0",
280
+ id,
281
+ error: { code: -32601, message: `Unknown tool '${toolName}'` },
282
+ };
283
+ }
284
+
285
+ return {
286
+ jsonrpc: "2.0",
287
+ id,
288
+ error: { code: -32601, message: `Method not found: '${method}'` },
289
+ };
290
+ } catch (err) {
291
+ return {
292
+ jsonrpc: "2.0",
293
+ id,
294
+ result: {
295
+ isError: true,
296
+ content: [{ type: "text", text: err.message }],
297
+ },
298
+ };
299
+ }
300
+ }
301
+
302
+ /**
303
+ * Start the stdio JSON-RPC 2.0 MCP server loop (supports newline-delimited JSON-RPC and Content-Length framing).
304
+ */
305
+ export function startStdioMcpServer({
306
+ stdin = process.stdin,
307
+ stdout = process.stdout,
308
+ cwd = process.cwd(),
309
+ env = process.env,
310
+ } = {}) {
311
+ let buffer = Buffer.alloc(0);
312
+ let useContentLength = false;
313
+
314
+ const sendResponse = (resObj) => {
315
+ if (!resObj) return;
316
+ const json = JSON.stringify(resObj);
317
+ if (useContentLength) {
318
+ const byteLen = Buffer.byteLength(json, "utf8");
319
+ stdout.write(`Content-Length: ${byteLen}\r\n\r\n${json}`);
320
+ } else {
321
+ stdout.write(`${json}\n`);
322
+ }
323
+ };
324
+
325
+ const drainBuffer = async () => {
326
+ while (buffer.length > 0) {
327
+ const asciiHead = buffer.subarray(0, Math.min(buffer.length, 32)).toString("utf8");
328
+ if (/^Content-Length:/i.test(asciiHead)) {
329
+ useContentLength = true;
330
+ const headerEnd = buffer.indexOf("\r\n\r\n");
331
+ if (headerEnd === -1) return;
332
+ const headerStr = buffer.subarray(0, headerEnd).toString("utf8");
333
+ const lenMatch = headerStr.match(/Content-Length:\s*(\d+)/i);
334
+ if (!lenMatch) {
335
+ buffer = buffer.subarray(headerEnd + 4);
336
+ continue;
337
+ }
338
+ const bodyLen = parseInt(lenMatch[1], 10);
339
+ const frameEnd = headerEnd + 4 + bodyLen;
340
+ if (buffer.length < frameEnd) return;
341
+ const bodyStr = buffer.subarray(headerEnd + 4, frameEnd).toString("utf8");
342
+ buffer = buffer.subarray(frameEnd);
343
+ try {
344
+ const parsed = JSON.parse(bodyStr);
345
+ const reply = await handleMcpJsonRpcRequest(parsed, { cwd, env });
346
+ sendResponse(reply);
347
+ } catch {
348
+ sendResponse({ jsonrpc: "2.0", id: null, error: { code: -32700, message: "Parse error" } });
349
+ }
350
+ } else {
351
+ const nl = buffer.indexOf(0x0a);
352
+ if (nl === -1) return;
353
+ const line = buffer.subarray(0, nl).toString("utf8").trim();
354
+ buffer = buffer.subarray(nl + 1);
355
+ if (!line) continue;
356
+ try {
357
+ const parsed = JSON.parse(line);
358
+ const reply = await handleMcpJsonRpcRequest(parsed, { cwd, env });
359
+ sendResponse(reply);
360
+ } catch {
361
+ sendResponse({ jsonrpc: "2.0", id: null, error: { code: -32700, message: "Parse error" } });
362
+ }
363
+ }
364
+ }
365
+ };
366
+
367
+ stdin.on("data", (chunk) => {
368
+ const bufChunk = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk), "utf8");
369
+ buffer = Buffer.concat([buffer, bufChunk]);
370
+ drainBuffer();
371
+ });
372
+ }
@@ -0,0 +1,59 @@
1
+ import { computeSummaryCounts, serializeCleanReportItem } from "../kernel/pipeline.mjs";
2
+ import { patchDocumentOnDisk } from "../kernel/patcher.mjs";
3
+
4
+ /**
5
+ * Batch Auto-Fix runner (`dislop fix --auto`):
6
+ * Automatically applies ONLY verified `fixSafety === "safe"` items (`replace` or `delete`),
7
+ * updating `report.summary` and `report.items` to reflect remaining unresolved findings.
8
+ */
9
+ export function runAutoFixOnDocumentResult(docResult, { dryRun = false, backup = false } = {}) {
10
+ const { doc, items, report } = docResult;
11
+
12
+ const safeItems = items.filter(
13
+ (item) =>
14
+ item.fixSafety === "safe" &&
15
+ (item.actionType === "delete" ||
16
+ (item.actionType === "replace" && item.suggestedReplacement !== "")),
17
+ );
18
+
19
+ if (safeItems.length === 0) {
20
+ return {
21
+ appliedCount: 0,
22
+ modified: false,
23
+ diff: "",
24
+ report,
25
+ };
26
+ }
27
+
28
+ const patches = safeItems.map((item) => ({
29
+ targetId: item.targetId,
30
+ locator: item._locator || null,
31
+ originalQuote: item.originalQuote,
32
+ replacement: item.actionType === "delete" ? "" : item.suggestedReplacement,
33
+ }));
34
+
35
+ const patchRes = patchDocumentOnDisk(doc, patches, {
36
+ dryRun,
37
+ backup,
38
+ displayPath: report.file,
39
+ });
40
+
41
+ if (patchRes.modified && !dryRun) {
42
+ const appliedIds = new Set(safeItems.map((i) => i.id));
43
+ for (const item of items) {
44
+ if (appliedIds.has(item.id)) {
45
+ item._applied = true;
46
+ }
47
+ }
48
+ const remaining = items.filter((i) => !i._applied);
49
+ report.summary = computeSummaryCounts(remaining);
50
+ report.items = remaining.map(serializeCleanReportItem);
51
+ }
52
+
53
+ return {
54
+ appliedCount: patchRes.modified ? safeItems.length : 0,
55
+ modified: patchRes.modified,
56
+ diff: patchRes.diff,
57
+ report,
58
+ };
59
+ }