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
@@ -0,0 +1,296 @@
1
+ import { execFileSync } from "node:child_process";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { DislopConfigError } from "./config.mjs";
5
+ import { detectFormatFromPath } from "./document-model.mjs";
6
+
7
+ const DEFAULT_IGNORED_DIRS = new Set([
8
+ ".git",
9
+ "node_modules",
10
+ "dist",
11
+ "build",
12
+ ".next",
13
+ "coverage",
14
+ "__pycache__",
15
+ ".venv",
16
+ "venv",
17
+ ]);
18
+
19
+ function resolveComparablePath(targetPath) {
20
+ const abs = path.resolve(targetPath);
21
+ if (fs.existsSync(abs)) {
22
+ return fs.realpathSync(abs);
23
+ }
24
+ const parent = path.dirname(abs);
25
+ if (fs.existsSync(parent)) {
26
+ return path.join(fs.realpathSync(parent), path.basename(abs));
27
+ }
28
+ return abs;
29
+ }
30
+
31
+ function expandBraces(pattern) {
32
+ const m = String(pattern || "").match(/\{([^{}]+)\}/);
33
+ if (!m) return [String(pattern || "")];
34
+ const prefix = pattern.slice(0, m.index);
35
+ const suffix = pattern.slice(m.index + m[0].length);
36
+ return m[1].split(",").flatMap((part) => expandBraces(prefix + part.trim() + suffix));
37
+ }
38
+
39
+ function globToRegExp(glob) {
40
+ const norm = String(glob || "")
41
+ .replace(/\\/g, "/")
42
+ .replace(/^\.\//, "");
43
+ let rx = "^";
44
+ for (let i = 0; i < norm.length; i += 1) {
45
+ const ch = norm[i];
46
+ if (ch === "*" && norm[i + 1] === "*") {
47
+ if (norm[i + 2] === "/") {
48
+ rx += "(?:.+/)?";
49
+ i += 2;
50
+ } else {
51
+ rx += ".*";
52
+ i += 1;
53
+ }
54
+ } else if (ch === "*") {
55
+ rx += "[^/]*";
56
+ } else if (ch === "?") {
57
+ rx += "[^/]";
58
+ } else if ("+.^$|()[]{}".includes(ch)) {
59
+ rx += `\\${ch}`;
60
+ } else {
61
+ rx += ch;
62
+ }
63
+ }
64
+ rx += "$";
65
+ return new RegExp(rx);
66
+ }
67
+
68
+ export function compileIgnoreMatchers(ignorePatterns = []) {
69
+ const fileRegexes = [];
70
+ const dirPrefixes = [];
71
+
72
+ for (const raw of ignorePatterns) {
73
+ const clean = String(raw || "")
74
+ .trim()
75
+ .replace(/\\/g, "/")
76
+ .replace(/^\.\//, "");
77
+ if (!clean) continue;
78
+
79
+ for (const pattern of expandBraces(clean)) {
80
+ if (pattern.endsWith("/**")) {
81
+ const prefix = pattern.slice(0, -3).replace(/\/+$/, "");
82
+ if (prefix) dirPrefixes.push(prefix);
83
+ } else if (pattern.endsWith("/")) {
84
+ const prefix = pattern.slice(0, -1);
85
+ if (prefix) {
86
+ dirPrefixes.push(prefix);
87
+ fileRegexes.push(globToRegExp(`${prefix}/**`));
88
+ continue;
89
+ }
90
+ }
91
+ fileRegexes.push(globToRegExp(pattern));
92
+ }
93
+ }
94
+
95
+ return (relPosix, isDirectory = false) => {
96
+ const norm = String(relPosix || "").replace(/\\/g, "/").replace(/^\.\//, "");
97
+ if (!norm) return false;
98
+ if (dirPrefixes.some((p) => norm === p || norm.startsWith(`${p}/`))) {
99
+ return true;
100
+ }
101
+ if (isDirectory) return false;
102
+ return fileRegexes.some((rx) => rx.test(norm));
103
+ };
104
+ }
105
+
106
+ function walkDirectorySupportedFiles(rootDir, ignoreRoot, isIgnored, collector) {
107
+ for (const entry of fs.readdirSync(rootDir, { withFileTypes: true })) {
108
+ const full = path.join(rootDir, entry.name);
109
+ const rel = path
110
+ .relative(ignoreRoot, resolveComparablePath(full))
111
+ .replace(/\\/g, "/");
112
+ if (entry.isDirectory()) {
113
+ if (DEFAULT_IGNORED_DIRS.has(entry.name) || isIgnored(rel, true)) continue;
114
+ walkDirectorySupportedFiles(full, ignoreRoot, isIgnored, collector);
115
+ } else if (entry.isFile()) {
116
+ if (isIgnored(rel, false)) continue;
117
+ if (detectFormatFromPath(full)) {
118
+ collector.push(full);
119
+ }
120
+ }
121
+ }
122
+ }
123
+
124
+ function walkAllFilesRelative(baseDir, relPrefix, ignoreRoot, isIgnored, collector) {
125
+ if (!fs.existsSync(baseDir)) return;
126
+ for (const entry of fs.readdirSync(baseDir, { withFileTypes: true })) {
127
+ const rel = relPrefix ? `${relPrefix}/${entry.name}` : entry.name;
128
+ const full = path.join(baseDir, entry.name);
129
+ const relIgnore = path
130
+ .relative(ignoreRoot, resolveComparablePath(full))
131
+ .replace(/\\/g, "/");
132
+ if (entry.isDirectory()) {
133
+ if (DEFAULT_IGNORED_DIRS.has(entry.name) || isIgnored(relIgnore, true)) continue;
134
+ walkAllFilesRelative(full, rel, ignoreRoot, isIgnored, collector);
135
+ } else if (entry.isFile()) {
136
+ if (isIgnored(relIgnore, false)) continue;
137
+ collector.push({ rel, full });
138
+ }
139
+ }
140
+ }
141
+
142
+ function hasGlobMagic(input) {
143
+ return /[*?{}]/.test(input);
144
+ }
145
+
146
+ /**
147
+ * Expand positional file, directory, and glob targets into sorted absolute file paths.
148
+ */
149
+ export function expandTargetInputs(
150
+ inputs,
151
+ { cwd = process.cwd(), ignorePatterns = [], projectRoot = null } = {},
152
+ ) {
153
+ if (!inputs || inputs.length === 0) {
154
+ throw new DislopConfigError("Missing target <files/globs...>. Example: dislop check README.md");
155
+ }
156
+
157
+ const ignoreRoot = resolveComparablePath(projectRoot || cwd);
158
+ const isIgnored = compileIgnoreMatchers(ignorePatterns);
159
+ const found = new Set();
160
+
161
+ for (const rawInput of inputs) {
162
+ const input = String(rawInput || "").trim();
163
+ if (!input) continue;
164
+
165
+ if (!hasGlobMagic(input)) {
166
+ const abs = path.resolve(cwd, input);
167
+ if (!fs.existsSync(abs)) {
168
+ throw new DislopConfigError(`Target path does not exist: '${input}'`);
169
+ }
170
+ const stat = fs.statSync(abs);
171
+ if (stat.isDirectory()) {
172
+ const dirFiles = [];
173
+ walkDirectorySupportedFiles(abs, ignoreRoot, isIgnored, dirFiles);
174
+ for (const f of dirFiles) found.add(f);
175
+ } else if (stat.isFile()) {
176
+ if (!detectFormatFromPath(abs)) {
177
+ throw new DislopConfigError(`Unsupported file extension: '${input}'`);
178
+ }
179
+ const relIgnore = path
180
+ .relative(ignoreRoot, resolveComparablePath(abs))
181
+ .replace(/\\/g, "/");
182
+ if (!isIgnored(relIgnore, false)) {
183
+ found.add(abs);
184
+ }
185
+ }
186
+ continue;
187
+ }
188
+
189
+ // Glob pattern expansion
190
+ const expandedPatterns = expandBraces(input);
191
+ const regexes = expandedPatterns.map(globToRegExp);
192
+ const candidates = [];
193
+ walkAllFilesRelative(cwd, "", ignoreRoot, isIgnored, candidates);
194
+
195
+ let matchedAny = false;
196
+ for (const cand of candidates) {
197
+ if (regexes.some((rx) => rx.test(cand.rel)) && detectFormatFromPath(cand.full)) {
198
+ found.add(cand.full);
199
+ matchedAny = true;
200
+ }
201
+ }
202
+ if (!matchedAny) {
203
+ throw new DislopConfigError(`Glob pattern matched no supported files: '${input}'`);
204
+ }
205
+ }
206
+
207
+ return Array.from(found).sort();
208
+ }
209
+
210
+ function splitNulBuffer(buf) {
211
+ if (!buf || buf.length === 0) return [];
212
+ return buf
213
+ .toString("utf8")
214
+ .split("\0")
215
+ .map((s) => s.trim())
216
+ .filter(Boolean);
217
+ }
218
+
219
+ /**
220
+ * Discover git-changed deliverable files (`--changed` or `--since <ref>`) using NUL-delimited output.
221
+ */
222
+ export function discoverChangedFiles({
223
+ cwd = process.cwd(),
224
+ since = null,
225
+ ignorePatterns = [],
226
+ projectRoot = null,
227
+ } = {}) {
228
+ let gitRoot;
229
+ try {
230
+ gitRoot = execFileSync("git", ["rev-parse", "--show-toplevel"], {
231
+ cwd,
232
+ encoding: "utf8",
233
+ stdio: ["ignore", "pipe", "pipe"],
234
+ }).trim();
235
+ } catch {
236
+ throw new DislopConfigError(
237
+ `'--changed' / '--since' requires a git repository (not found from '${cwd}').`,
238
+ );
239
+ }
240
+
241
+ const relCandidates = new Set();
242
+ const collectGitZ = (args) => {
243
+ const out = execFileSync("git", args, {
244
+ cwd: gitRoot,
245
+ encoding: null,
246
+ stdio: ["ignore", "pipe", "pipe"],
247
+ });
248
+ for (const rel of splitNulBuffer(out)) {
249
+ relCandidates.add(rel);
250
+ }
251
+ };
252
+
253
+ if (since) {
254
+ try {
255
+ collectGitZ(["diff", "-z", "--name-only", "--diff-filter=ACMR", since]);
256
+ } catch (err) {
257
+ throw new DislopConfigError(`Invalid git ref '${since}' for --since: ${err.message}`);
258
+ }
259
+ } else {
260
+ let hasHead = false;
261
+ try {
262
+ execFileSync("git", ["rev-parse", "--verify", "HEAD"], {
263
+ cwd: gitRoot,
264
+ stdio: "ignore",
265
+ });
266
+ hasHead = true;
267
+ } catch {
268
+ hasHead = false;
269
+ }
270
+ if (hasHead) {
271
+ collectGitZ(["diff", "-z", "--name-only", "--diff-filter=ACMR", "HEAD"]);
272
+ } else {
273
+ collectGitZ(["diff", "--cached", "-z", "--name-only", "--diff-filter=ACMR"]);
274
+ }
275
+ }
276
+ collectGitZ(["ls-files", "-z", "--others", "--exclude-standard"]);
277
+
278
+ const realGitRoot = resolveComparablePath(gitRoot);
279
+ const ignoreRoot = resolveComparablePath(projectRoot || gitRoot);
280
+ const isIgnored = compileIgnoreMatchers(ignorePatterns);
281
+ const resolved = new Set();
282
+ for (const rel of relCandidates) {
283
+ const abs = path.resolve(realGitRoot, rel);
284
+ if (!fs.existsSync(abs) || !fs.statSync(abs).isFile()) continue;
285
+ const realAbs = resolveComparablePath(abs);
286
+ const relFromRoot = path.relative(realGitRoot, realAbs).replace(/\\/g, "/");
287
+ // Confine symlinked targets inside the canonical git repository root
288
+ if (relFromRoot.startsWith("..") || path.isAbsolute(relFromRoot)) continue;
289
+ if (!detectFormatFromPath(abs)) continue;
290
+ const relFromIgnore = path.relative(ignoreRoot, realAbs).replace(/\\/g, "/");
291
+ if (isIgnored(relFromIgnore, false) || isIgnored(relFromRoot, false)) continue;
292
+ resolved.add(abs);
293
+ }
294
+
295
+ return Array.from(resolved).sort();
296
+ }