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.
- 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 -63
- package/README.md +358 -249
- package/README.zh-CN.md +391 -237
- package/action.yml +30 -39
- package/bin/dislop-mcp.mjs +3 -4
- package/bin/dislop.mjs +4 -4594
- package/gemini-extension.json +2 -2
- package/llms-install.md +68 -0
- package/package.json +17 -63
- 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 +235 -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 +293 -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 +2 -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/agents/openai.yaml +1 -1
- package/skills/dislop/references/essay.md +6 -6
- package/skills/dislop/references/essay.zh-CN.md +6 -6
- package/skills/dislop/references/office.md +5 -5
- package/skills/dislop/references/office.zh-CN.md +5 -5
- package/skills/dislop/references/web-ui.md +4 -4
- package/skills/dislop/references/web-ui.zh-CN.md +4 -4
- package/skills/dislop/references/work-docs.md +7 -7
- package/skills/dislop/references/work-docs.zh-CN.md +7 -7
- package/src/cli-main.mjs +292 -0
- package/src/commands/check-fix.mjs +324 -0
- package/src/commands/doctor.mjs +132 -0
- package/src/commands/init.mjs +55 -0
- package/src/commands/login.mjs +82 -0
- package/src/commands/model.mjs +130 -0
- package/src/commands/packs.mjs +81 -0
- package/src/commands/verify.mjs +165 -0
- package/src/commands/voice.mjs +84 -0
- package/src/commands/worklog.mjs +424 -0
- package/src/kernel/config.mjs +759 -0
- package/src/kernel/document-model.mjs +1432 -0
- package/src/kernel/fact-gate.mjs +775 -0
- package/src/kernel/file-discovery.mjs +296 -0
- package/src/{binary-node.mjs → kernel/ooxml-binary.mjs} +615 -890
- package/src/kernel/pack-loader.mjs +801 -0
- package/src/kernel/pack-validator.mjs +491 -0
- package/src/kernel/patcher.mjs +471 -0
- package/src/kernel/pipeline.mjs +530 -0
- package/src/kernel/prompt-assembler.mjs +336 -0
- package/src/kernel/version.mjs +7 -0
- package/src/kernel/voice-profile.mjs +180 -0
- package/src/mcp/stdio-server.mjs +442 -0
- package/src/runners/auto-fix.mjs +74 -0
- package/src/runners/interactive-tty.mjs +488 -0
- package/src/runners/reporters.mjs +272 -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 +138 -0
- package/src/runtime/providers/gemini.mjs +91 -0
- package/src/runtime/providers/local-model.mjs +147 -0
- package/src/runtime/providers/openai-compat.mjs +130 -0
- package/src/runtime/router.mjs +324 -0
- package/src/runtime/worklog.mjs +904 -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
|
@@ -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
|
+
}
|