dislop 1.0.1 → 1.1.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 +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.cursor-plugin/plugin.json +1 -1
- package/PRODUCT.md +2 -2
- package/README.md +34 -33
- package/README.zh-CN.md +65 -61
- package/action.yml +17 -2
- package/gemini-extension.json +1 -1
- package/package.json +2 -2
- package/packs/common/artifact-qa/scripts/index.mjs +64 -2
- package/packs/en/artifact-qa/scripts/index.mjs +1 -1
- package/packs/en/prose/scripts/index.mjs +3 -0
- package/plugin.json +1 -1
- package/server.json +2 -2
- package/skills/dislop/SKILL.md +1 -1
- package/skills/dislop/agents/openai.yaml +1 -1
- package/skills/dislop/references/essay.md +5 -5
- package/skills/dislop/references/essay.zh-CN.md +5 -5
- package/skills/dislop/references/office.md +4 -4
- package/skills/dislop/references/office.zh-CN.md +4 -4
- 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 +6 -6
- package/skills/dislop/references/work-docs.zh-CN.md +6 -6
- package/src/cli-main.mjs +88 -6
- package/src/commands/check-fix.mjs +170 -15
- package/src/commands/doctor.mjs +23 -1
- package/src/commands/init.mjs +24 -18
- package/src/commands/packs.mjs +41 -4
- package/src/commands/verify.mjs +36 -4
- package/src/commands/voice.mjs +1 -1
- package/src/commands/worklog.mjs +424 -0
- package/src/kernel/config.mjs +546 -19
- package/src/kernel/document-model.mjs +30 -10
- package/src/kernel/fact-gate.mjs +160 -0
- package/src/kernel/file-discovery.mjs +168 -11
- package/src/kernel/ooxml-binary.mjs +86 -0
- package/src/kernel/pack-loader.mjs +107 -21
- package/src/kernel/pack-validator.mjs +491 -0
- package/src/kernel/patcher.mjs +177 -47
- package/src/kernel/pipeline.mjs +284 -21
- package/src/kernel/prompt-assembler.mjs +37 -8
- package/src/kernel/version.mjs +7 -0
- package/src/kernel/voice-profile.mjs +3 -0
- package/src/mcp/stdio-server.mjs +71 -1
- package/src/runners/auto-fix.mjs +17 -2
- package/src/runners/interactive-tty.mjs +32 -5
- package/src/runners/reporters.mjs +18 -2
- package/src/runtime/providers/cloud.mjs +4 -2
- package/src/runtime/providers/local-model.mjs +8 -0
- package/src/runtime/router.mjs +11 -2
- package/src/runtime/worklog.mjs +904 -0
|
@@ -1,14 +1,45 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
1
3
|
import { DislopConfigError, isInteractiveHumanTty, resolveLayeredConfig } from "../kernel/config.mjs";
|
|
2
|
-
import { expandTargetInputs } from "../kernel/file-discovery.mjs";
|
|
4
|
+
import { discoverChangedFiles, expandTargetInputs } from "../kernel/file-discovery.mjs";
|
|
3
5
|
import { arbitrateExitCode, runDocumentPipeline } from "../kernel/pipeline.mjs";
|
|
4
6
|
import { resolveOrExtractVoiceProfile } from "../kernel/voice-profile.mjs";
|
|
5
7
|
import { runAutoFixOnDocumentResult } from "../runners/auto-fix.mjs";
|
|
6
8
|
import { runInteractiveTtySession } from "../runners/interactive-tty.mjs";
|
|
7
9
|
import { renderReports } from "../runners/reporters.mjs";
|
|
8
10
|
import { resolveExecutionRoute } from "../runtime/router.mjs";
|
|
11
|
+
import { buildCheckOrFixWorklogEntry, recordWorklogEntry } from "../runtime/worklog.mjs";
|
|
9
12
|
|
|
10
13
|
const VALID_FORMATS = new Set(["text", "diff", "json", "agent", "sarif"]);
|
|
11
14
|
|
|
15
|
+
async function readStreamBuffer(stream, preloaded = null) {
|
|
16
|
+
if (Buffer.isBuffer(preloaded)) return preloaded;
|
|
17
|
+
if (typeof preloaded === "string") return Buffer.from(preloaded, "utf8");
|
|
18
|
+
if (!stream) return Buffer.alloc(0);
|
|
19
|
+
const chunks = [];
|
|
20
|
+
for await (const chunk of stream) {
|
|
21
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk), "utf8"));
|
|
22
|
+
}
|
|
23
|
+
return Buffer.concat(chunks);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function mapWithConcurrency(items, concurrency, worker) {
|
|
27
|
+
const limit = Math.max(1, Math.min(concurrency || 1, items.length || 1));
|
|
28
|
+
const results = new Array(items.length);
|
|
29
|
+
let nextIdx = 0;
|
|
30
|
+
|
|
31
|
+
async function runWorker() {
|
|
32
|
+
while (nextIdx < items.length) {
|
|
33
|
+
const idx = nextIdx;
|
|
34
|
+
nextIdx += 1;
|
|
35
|
+
results[idx] = await worker(items[idx], idx);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
await Promise.all(Array.from({ length: limit }, () => runWorker()));
|
|
40
|
+
return results;
|
|
41
|
+
}
|
|
42
|
+
|
|
12
43
|
/**
|
|
13
44
|
* `dislop check <files/globs...> [options]` — strictly read-only inspection.
|
|
14
45
|
*/
|
|
@@ -23,6 +54,7 @@ export async function runCheckCommand(targets, flags, io = {}) {
|
|
|
23
54
|
promptFn = null,
|
|
24
55
|
} = io;
|
|
25
56
|
|
|
57
|
+
const startedAt = Date.now();
|
|
26
58
|
const format = flags.json ? "json" : flags.format || "text";
|
|
27
59
|
if (!VALID_FORMATS.has(format)) {
|
|
28
60
|
throw new DislopConfigError(
|
|
@@ -30,9 +62,50 @@ export async function runCheckCommand(targets, flags, io = {}) {
|
|
|
30
62
|
);
|
|
31
63
|
}
|
|
32
64
|
|
|
33
|
-
const files = expandTargetInputs(targets, { cwd });
|
|
34
65
|
const isTty = isInteractiveHumanTty({ stdin, stdout, env });
|
|
35
66
|
const config = resolveLayeredConfig({ cwd, env, cliFlags: flags });
|
|
67
|
+
|
|
68
|
+
const hasStdinTarget = Array.isArray(targets) && targets.includes("-");
|
|
69
|
+
if (hasStdinTarget && targets.length > 1) {
|
|
70
|
+
throw new DislopConfigError("Cannot mix '-' (stdin) with additional file paths.");
|
|
71
|
+
}
|
|
72
|
+
if ((flags.changed || flags.since) && targets && targets.length > 0) {
|
|
73
|
+
throw new DislopConfigError("Cannot combine '--changed' / '--since' with explicit file targets.");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let files = [];
|
|
77
|
+
let stdinBufferContent = null;
|
|
78
|
+
if (hasStdinTarget) {
|
|
79
|
+
stdinBufferContent = await readStreamBuffer(stdin, io.stdinText ?? null);
|
|
80
|
+
const virtualName = flags.stdinFilename || "stdin.md";
|
|
81
|
+
files = [path.resolve(cwd, virtualName)];
|
|
82
|
+
} else if (flags.changed || flags.since) {
|
|
83
|
+
files = discoverChangedFiles({
|
|
84
|
+
cwd,
|
|
85
|
+
since: flags.since || null,
|
|
86
|
+
ignorePatterns: config.ignore,
|
|
87
|
+
projectRoot: config.projectDir || cwd,
|
|
88
|
+
});
|
|
89
|
+
} else {
|
|
90
|
+
files = expandTargetInputs(targets, {
|
|
91
|
+
cwd,
|
|
92
|
+
ignorePatterns: config.ignore,
|
|
93
|
+
projectRoot: config.projectDir || cwd,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (files.length === 0) {
|
|
98
|
+
const emptyMsg = flags.changed || flags.since
|
|
99
|
+
? "No changed deliverable files to check.\n"
|
|
100
|
+
: "No matching deliverable files to check.\n";
|
|
101
|
+
if (format === "json") {
|
|
102
|
+
stdout.write("[]\n");
|
|
103
|
+
} else {
|
|
104
|
+
stdout.write(emptyMsg);
|
|
105
|
+
}
|
|
106
|
+
return 0;
|
|
107
|
+
}
|
|
108
|
+
|
|
36
109
|
const route = await resolveExecutionRoute({
|
|
37
110
|
config,
|
|
38
111
|
isTty,
|
|
@@ -43,24 +116,32 @@ export async function runCheckCommand(targets, flags, io = {}) {
|
|
|
43
116
|
promptFn,
|
|
44
117
|
});
|
|
45
118
|
|
|
46
|
-
const voiceProfile = await resolveOrExtractVoiceProfile(config, { route });
|
|
47
|
-
|
|
48
|
-
const results = [];
|
|
49
|
-
let emittedHint = false;
|
|
119
|
+
const voiceProfile = config.noLlm ? null : await resolveOrExtractVoiceProfile(config, { route });
|
|
120
|
+
const workerCount = config.concurrency || (route?.execute ? Math.min(4, files.length) : 1);
|
|
50
121
|
|
|
51
|
-
|
|
52
|
-
|
|
122
|
+
const rawResults = await mapWithConcurrency(files, workerCount, (filePath) =>
|
|
123
|
+
runDocumentPipeline({
|
|
53
124
|
filePath,
|
|
125
|
+
bufferContent: hasStdinTarget ? stdinBufferContent : null,
|
|
54
126
|
config,
|
|
55
127
|
route,
|
|
56
128
|
voiceProfile,
|
|
57
129
|
cwd,
|
|
58
|
-
})
|
|
130
|
+
}),
|
|
131
|
+
);
|
|
132
|
+
const results = rawResults.filter((r) => !r.skippedByIgnore);
|
|
133
|
+
|
|
134
|
+
if (results.length === 0) {
|
|
135
|
+
stdout.write(format === "json" ? "[]\n" : "No matching deliverable files to check.\n");
|
|
136
|
+
return 0;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
let emittedHint = false;
|
|
140
|
+
for (const res of results) {
|
|
59
141
|
if (res.routeHint && !emittedHint) {
|
|
60
142
|
stderr.write(`${res.routeHint}\n`);
|
|
61
143
|
emittedHint = true;
|
|
62
144
|
}
|
|
63
|
-
results.push(res);
|
|
64
145
|
}
|
|
65
146
|
|
|
66
147
|
const uiLang =
|
|
@@ -73,7 +154,26 @@ export async function runCheckCommand(targets, flags, io = {}) {
|
|
|
73
154
|
stdout.write(rendered);
|
|
74
155
|
}
|
|
75
156
|
|
|
76
|
-
|
|
157
|
+
const exitCode = arbitrateExitCode(results, {
|
|
158
|
+
failOn: config.failOn,
|
|
159
|
+
explicitFailOn: config.explicitFailOn,
|
|
160
|
+
});
|
|
161
|
+
recordWorklogEntry(
|
|
162
|
+
buildCheckOrFixWorklogEntry({
|
|
163
|
+
source: "cli",
|
|
164
|
+
command: "check",
|
|
165
|
+
mode: format,
|
|
166
|
+
cwd,
|
|
167
|
+
config,
|
|
168
|
+
route,
|
|
169
|
+
results,
|
|
170
|
+
durationMs: Date.now() - startedAt,
|
|
171
|
+
exitCode,
|
|
172
|
+
}),
|
|
173
|
+
config,
|
|
174
|
+
env,
|
|
175
|
+
);
|
|
176
|
+
return exitCode;
|
|
77
177
|
}
|
|
78
178
|
|
|
79
179
|
/**
|
|
@@ -95,6 +195,7 @@ export async function runFixCommand(targets, flags, io = {}) {
|
|
|
95
195
|
clipboardRunner = null,
|
|
96
196
|
} = io;
|
|
97
197
|
|
|
198
|
+
const startedAt = Date.now();
|
|
98
199
|
const isAuto = Boolean(flags.auto || flags.yes);
|
|
99
200
|
const isTty = isInteractiveHumanTty({ stdin, stdout, env }) || Boolean(keyReader);
|
|
100
201
|
|
|
@@ -104,8 +205,27 @@ export async function runFixCommand(targets, flags, io = {}) {
|
|
|
104
205
|
);
|
|
105
206
|
}
|
|
106
207
|
|
|
107
|
-
const files = expandTargetInputs(targets, { cwd });
|
|
108
208
|
const config = resolveLayeredConfig({ cwd, env, cliFlags: flags });
|
|
209
|
+
if (Array.isArray(targets) && targets.includes("-")) {
|
|
210
|
+
throw new DislopConfigError("'dislop fix' does not modify '-' (stdin). Pass file paths or run 'dislop check - --format diff'.");
|
|
211
|
+
}
|
|
212
|
+
const files =
|
|
213
|
+
flags.changed || flags.since
|
|
214
|
+
? discoverChangedFiles({
|
|
215
|
+
cwd,
|
|
216
|
+
since: flags.since || null,
|
|
217
|
+
ignorePatterns: config.ignore,
|
|
218
|
+
projectRoot: config.projectDir || cwd,
|
|
219
|
+
})
|
|
220
|
+
: expandTargetInputs(targets, {
|
|
221
|
+
cwd,
|
|
222
|
+
ignorePatterns: config.ignore,
|
|
223
|
+
projectRoot: config.projectDir || cwd,
|
|
224
|
+
});
|
|
225
|
+
if (files.length === 0) {
|
|
226
|
+
stdout.write("No matching deliverable files to fix.\n");
|
|
227
|
+
return 0;
|
|
228
|
+
}
|
|
109
229
|
const route = await resolveExecutionRoute({
|
|
110
230
|
config,
|
|
111
231
|
isTty,
|
|
@@ -115,9 +235,11 @@ export async function runFixCommand(targets, flags, io = {}) {
|
|
|
115
235
|
fetchImpl,
|
|
116
236
|
promptFn,
|
|
117
237
|
});
|
|
118
|
-
const voiceProfile = await resolveOrExtractVoiceProfile(config, { route });
|
|
238
|
+
const voiceProfile = config.noLlm ? null : await resolveOrExtractVoiceProfile(config, { route });
|
|
119
239
|
|
|
120
240
|
const results = [];
|
|
241
|
+
const decisionsByFile = [];
|
|
242
|
+
let aborted = false;
|
|
121
243
|
let emittedHint = false;
|
|
122
244
|
|
|
123
245
|
for (const filePath of files) {
|
|
@@ -128,6 +250,7 @@ export async function runFixCommand(targets, flags, io = {}) {
|
|
|
128
250
|
voiceProfile,
|
|
129
251
|
cwd,
|
|
130
252
|
});
|
|
253
|
+
if (docRes.skippedByIgnore) continue;
|
|
131
254
|
if (docRes.routeHint && !emittedHint) {
|
|
132
255
|
stderr.write(`${docRes.routeHint}\n`);
|
|
133
256
|
emittedHint = true;
|
|
@@ -146,8 +269,13 @@ export async function runFixCommand(targets, flags, io = {}) {
|
|
|
146
269
|
);
|
|
147
270
|
}
|
|
148
271
|
results.push(docRes);
|
|
272
|
+
decisionsByFile.push({
|
|
273
|
+
decisions: fixRes.decisions || {},
|
|
274
|
+
undoCount: 0,
|
|
275
|
+
aborted: false,
|
|
276
|
+
});
|
|
149
277
|
} else {
|
|
150
|
-
await runInteractiveTtySession(docRes, {
|
|
278
|
+
const ttyRes = await runInteractiveTtySession(docRes, {
|
|
151
279
|
stdin,
|
|
152
280
|
stdout,
|
|
153
281
|
env,
|
|
@@ -157,7 +285,13 @@ export async function runFixCommand(targets, flags, io = {}) {
|
|
|
157
285
|
editorRunner,
|
|
158
286
|
clipboardRunner,
|
|
159
287
|
});
|
|
288
|
+
if (ttyRes.aborted) aborted = true;
|
|
160
289
|
results.push(docRes);
|
|
290
|
+
decisionsByFile.push({
|
|
291
|
+
decisions: ttyRes.decisions || {},
|
|
292
|
+
undoCount: ttyRes.undoCount || 0,
|
|
293
|
+
aborted: Boolean(ttyRes.aborted),
|
|
294
|
+
});
|
|
161
295
|
}
|
|
162
296
|
}
|
|
163
297
|
|
|
@@ -165,5 +299,26 @@ export async function runFixCommand(targets, flags, io = {}) {
|
|
|
165
299
|
stdout.write(renderReports(results, "json"));
|
|
166
300
|
}
|
|
167
301
|
|
|
168
|
-
|
|
302
|
+
const exitCode = arbitrateExitCode(results, {
|
|
303
|
+
failOn: config.failOn,
|
|
304
|
+
explicitFailOn: config.explicitFailOn,
|
|
305
|
+
});
|
|
306
|
+
recordWorklogEntry(
|
|
307
|
+
buildCheckOrFixWorklogEntry({
|
|
308
|
+
source: "cli",
|
|
309
|
+
command: "fix",
|
|
310
|
+
mode: isAuto ? (flags.dryRun ? "auto-dry-run" : "auto") : (flags.dryRun ? "tty-dry-run" : "tty"),
|
|
311
|
+
cwd,
|
|
312
|
+
config,
|
|
313
|
+
route,
|
|
314
|
+
results,
|
|
315
|
+
decisionsByFile,
|
|
316
|
+
durationMs: Date.now() - startedAt,
|
|
317
|
+
exitCode,
|
|
318
|
+
aborted,
|
|
319
|
+
}),
|
|
320
|
+
config,
|
|
321
|
+
env,
|
|
322
|
+
);
|
|
323
|
+
return exitCode;
|
|
169
324
|
}
|
package/src/commands/doctor.mjs
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
isCiEnvironment,
|
|
4
|
+
isInteractiveHumanTty,
|
|
5
|
+
resolveLayeredConfig,
|
|
6
|
+
} from "../kernel/config.mjs";
|
|
3
7
|
import { listBuiltinPackIds } from "../kernel/pack-loader.mjs";
|
|
4
8
|
import {
|
|
5
9
|
detectOllamaBinary,
|
|
@@ -10,6 +14,7 @@ import {
|
|
|
10
14
|
resolveExecutionRoute,
|
|
11
15
|
resolveTier2ProviderCandidate,
|
|
12
16
|
} from "../runtime/router.mjs";
|
|
17
|
+
import { isWorklogActive } from "../runtime/worklog.mjs";
|
|
13
18
|
|
|
14
19
|
/**
|
|
15
20
|
* `dislop doctor [--json]` — zero-network diagnostic snapshot of config, active tier, auth, voice, and Packs.
|
|
@@ -66,6 +71,14 @@ export async function runDoctorCommand(_positionals, flags, io = {}) {
|
|
|
66
71
|
installed: Object.keys(modelsManifest.installed),
|
|
67
72
|
},
|
|
68
73
|
voiceCachePresent: Boolean(config.voice?.cachePath && fs.existsSync(config.voice.cachePath)),
|
|
74
|
+
worklog: {
|
|
75
|
+
enabled: config.worklog.enabled,
|
|
76
|
+
active: isWorklogActive(config, env),
|
|
77
|
+
ciDisabled: isCiEnvironment(env),
|
|
78
|
+
privacy: config.worklog.privacy,
|
|
79
|
+
dir: config.worklog.dir,
|
|
80
|
+
retentionDays: config.worklog.retentionDays,
|
|
81
|
+
},
|
|
69
82
|
configuredPacks: config.packs || ["(auto by document format & language)"],
|
|
70
83
|
builtinPacks,
|
|
71
84
|
};
|
|
@@ -104,6 +117,15 @@ export async function runDoctorCommand(_positionals, flags, io = {}) {
|
|
|
104
117
|
} (${ollamaStatusText})\n`,
|
|
105
118
|
);
|
|
106
119
|
stdout.write(` Voice Profile : ${diagnosis.voiceCachePresent ? "cached" : "not configured"}\n`);
|
|
120
|
+
stdout.write(
|
|
121
|
+
` Worklog : ${
|
|
122
|
+
diagnosis.worklog.active
|
|
123
|
+
? `active (privacy=${diagnosis.worklog.privacy}, dir=${diagnosis.worklog.dir})`
|
|
124
|
+
: diagnosis.worklog.ciDisabled
|
|
125
|
+
? "disabled in CI"
|
|
126
|
+
: "disabled (local opt-in only)"
|
|
127
|
+
}\n`,
|
|
128
|
+
);
|
|
107
129
|
stdout.write(` Built-in Packs : ${diagnosis.builtinPacks.join(", ")}\n`);
|
|
108
130
|
|
|
109
131
|
return 0;
|
package/src/commands/init.mjs
CHANGED
|
@@ -19,24 +19,30 @@ export async function runInitCommand(_positionals, flags, io = {}) {
|
|
|
19
19
|
|
|
20
20
|
const voiceRefs = flags.voiceFiles && flags.voiceFiles.length > 0 ? flags.voiceFiles : [];
|
|
21
21
|
|
|
22
|
-
const template =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
22
|
+
const template = flags.global
|
|
23
|
+
? {
|
|
24
|
+
routing: "local",
|
|
25
|
+
approvedHosts: [],
|
|
26
|
+
packs: ["artifact-qa", "web-ui", "slide-deck", "prose"],
|
|
27
|
+
voice: {
|
|
28
|
+
referenceFiles: voiceRefs,
|
|
29
|
+
},
|
|
30
|
+
providers: {
|
|
31
|
+
"local-ollama": {
|
|
32
|
+
protocol: "openai",
|
|
33
|
+
baseUrl: "http://127.0.0.1:11434/v1",
|
|
34
|
+
apiKey: "ollama",
|
|
35
|
+
model: "qwen2.5:7b",
|
|
36
|
+
structuredOutput: "json_object",
|
|
37
|
+
maxInputTokens: 8000,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
: {
|
|
42
|
+
routing: "local",
|
|
43
|
+
ignore: [".private/**"],
|
|
44
|
+
...(voiceRefs.length > 0 ? { voice: { referenceFiles: voiceRefs } } : {}),
|
|
45
|
+
};
|
|
40
46
|
|
|
41
47
|
if (flags.global) {
|
|
42
48
|
writeJsonFileSecure(targetPath, template, { mode: 0o600 });
|
package/src/commands/packs.mjs
CHANGED
|
@@ -1,11 +1,48 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { DislopConfigError } from "../kernel/config.mjs";
|
|
1
4
|
import { listBuiltinPackIds, loadSinglePack } from "../kernel/pack-loader.mjs";
|
|
5
|
+
import { validatePackPath } from "../kernel/pack-validator.mjs";
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
|
-
* `dislop packs [--json]` — inspect built-in
|
|
5
|
-
*
|
|
8
|
+
* `dislop packs [list | lint <path>] [--json]` — inspect built-in Packs via `pack.json` metadata
|
|
9
|
+
* or validate external `.pack.md` / Pack directories against security & schema checks.
|
|
6
10
|
*/
|
|
7
|
-
export async function runPacksCommand(
|
|
8
|
-
const { cwd = process.cwd(), stdout = process.stdout } = io;
|
|
11
|
+
export async function runPacksCommand(positionals = [], flags = {}, io = {}) {
|
|
12
|
+
const { cwd = process.cwd(), stdout = process.stdout, stderr = process.stderr } = io;
|
|
13
|
+
const subcommand = (positionals[0] || "list").trim();
|
|
14
|
+
|
|
15
|
+
if (subcommand === "lint" || subcommand === "validate") {
|
|
16
|
+
const target = positionals[1];
|
|
17
|
+
if (!target) {
|
|
18
|
+
throw new DislopConfigError("Usage: dislop packs lint <pack-dir|file.pack.md>");
|
|
19
|
+
}
|
|
20
|
+
const result = validatePackPath(target, { cwd });
|
|
21
|
+
if (!result.exists) {
|
|
22
|
+
throw new DislopConfigError(`Pack path does not exist: ${target}`);
|
|
23
|
+
}
|
|
24
|
+
if (flags.json || flags.format === "json") {
|
|
25
|
+
stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
26
|
+
} else if (result.ok) {
|
|
27
|
+
const relTarget = path.relative(cwd, result.targetPath) || ".";
|
|
28
|
+
stdout.write(
|
|
29
|
+
`OK ${relTarget}: ${result.checkedFiles} file(s) validated with 0 violations.\n`,
|
|
30
|
+
);
|
|
31
|
+
} else {
|
|
32
|
+
for (const v of result.violations) {
|
|
33
|
+
const rel = path.relative(cwd, v.file) || v.file;
|
|
34
|
+
const loc = v.line ? `:${v.line}` : "";
|
|
35
|
+
stderr.write(`FAIL [${v.ruleId}] ${rel}${loc}: ${v.message}\n`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return result.ok ? 0 : 1;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (subcommand !== "list") {
|
|
42
|
+
throw new DislopConfigError(
|
|
43
|
+
`Unknown packs subcommand '${subcommand}'. Expected 'list', 'lint', or 'validate'.`,
|
|
44
|
+
);
|
|
45
|
+
}
|
|
9
46
|
|
|
10
47
|
const ids = listBuiltinPackIds();
|
|
11
48
|
const details = [];
|
package/src/commands/verify.mjs
CHANGED
|
@@ -3,15 +3,22 @@ import crypto from "node:crypto";
|
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import os from "node:os";
|
|
5
5
|
import path from "node:path";
|
|
6
|
-
import { DislopConfigError } from "../kernel/config.mjs";
|
|
6
|
+
import { DislopConfigError, resolveLayeredConfig } from "../kernel/config.mjs";
|
|
7
7
|
import { detectFormatFromPath, parseDocumentFile, parseDocumentText } from "../kernel/document-model.mjs";
|
|
8
8
|
import { verifyDocumentRevision } from "../kernel/fact-gate.mjs";
|
|
9
|
+
import { buildVerifyWorklogEntry, recordWorklogEntry } from "../runtime/worklog.mjs";
|
|
9
10
|
|
|
10
11
|
function extractComparableText(filePath) {
|
|
11
12
|
const doc = parseDocumentFile(filePath);
|
|
12
13
|
if (doc.segments.length > 0) {
|
|
13
14
|
return doc.segments.map((s) => s.text).join("\n");
|
|
14
15
|
}
|
|
16
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
17
|
+
if ([".pdf", ".docx", ".pptx", ".png", ".jpg", ".jpeg", ".webp", ".gif"].includes(ext)) {
|
|
18
|
+
throw new DislopConfigError(
|
|
19
|
+
`Unable to extract inspectable text segments from binary file '${filePath}'. Cannot verify unextractable binary artifacts.`,
|
|
20
|
+
);
|
|
21
|
+
}
|
|
15
22
|
return fs.readFileSync(filePath, "utf8");
|
|
16
23
|
}
|
|
17
24
|
|
|
@@ -44,7 +51,8 @@ function extractComparableTextFromBuffer(buf, targetPath) {
|
|
|
44
51
|
* or `dislop verify --git [ref] <file> [--json]`
|
|
45
52
|
*/
|
|
46
53
|
export async function runVerifyCommand(positionals, flags, io = {}) {
|
|
47
|
-
const { cwd = process.cwd(), stdout = process.stdout } = io;
|
|
54
|
+
const { cwd = process.cwd(), env = process.env, stdout = process.stdout } = io;
|
|
55
|
+
const startedAt = Date.now();
|
|
48
56
|
|
|
49
57
|
let beforeText = "";
|
|
50
58
|
let afterText = "";
|
|
@@ -118,7 +126,9 @@ export async function runVerifyCommand(positionals, flags, io = {}) {
|
|
|
118
126
|
if (flags.json || flags.format === "json") {
|
|
119
127
|
stdout.write(`${JSON.stringify(payload, null, 2)}\n`);
|
|
120
128
|
} else if (verification.ok) {
|
|
121
|
-
stdout.write(
|
|
129
|
+
stdout.write(
|
|
130
|
+
`PASS ${label}: anchored tokens & qualifiers preserved; 0 detected slop/polarity regressions.\n`,
|
|
131
|
+
);
|
|
122
132
|
} else {
|
|
123
133
|
stdout.write(`FAIL ${label}:\n`);
|
|
124
134
|
for (const reason of verification.droppedFacts) {
|
|
@@ -129,5 +139,27 @@ export async function runVerifyCommand(positionals, flags, io = {}) {
|
|
|
129
139
|
}
|
|
130
140
|
}
|
|
131
141
|
|
|
132
|
-
|
|
142
|
+
const exitCode = verification.ok ? 0 : 1;
|
|
143
|
+
try {
|
|
144
|
+
const config = resolveLayeredConfig({ cwd, env, cliFlags: flags });
|
|
145
|
+
recordWorklogEntry(
|
|
146
|
+
buildVerifyWorklogEntry({
|
|
147
|
+
source: "cli",
|
|
148
|
+
command: "verify",
|
|
149
|
+
mode: flags.git !== undefined && flags.git !== false ? "verify-git" : "verify-files",
|
|
150
|
+
cwd,
|
|
151
|
+
config,
|
|
152
|
+
targetLabel: label,
|
|
153
|
+
verification,
|
|
154
|
+
durationMs: Date.now() - startedAt,
|
|
155
|
+
exitCode,
|
|
156
|
+
}),
|
|
157
|
+
config,
|
|
158
|
+
env,
|
|
159
|
+
);
|
|
160
|
+
} catch {
|
|
161
|
+
// Worklog recording must never break verify
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return exitCode;
|
|
133
165
|
}
|
package/src/commands/voice.mjs
CHANGED
|
@@ -63,7 +63,7 @@ export async function runVoiceCommand(positionals, flags, io = {}) {
|
|
|
63
63
|
"Usage: dislop voice extract <files/globs...> (no reference files provided)",
|
|
64
64
|
);
|
|
65
65
|
}
|
|
66
|
-
const resolvedFiles = expandTargetInputs(fileInputs, { cwd });
|
|
66
|
+
const resolvedFiles = expandTargetInputs(fileInputs, { cwd, ignorePatterns: config.ignore });
|
|
67
67
|
const isTty = isInteractiveHumanTty({ stdin, stdout, env });
|
|
68
68
|
const route = await resolveExecutionRoute({ config, isTty, env, stdin, stderr, fetchImpl });
|
|
69
69
|
const profile = await extractVoiceProfile(resolvedFiles, { route });
|