dislop 1.0.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 +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/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 +3 -3
- package/skills/dislop/references/web-ui.zh-CN.md +3 -3
- 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
package/src/runners/auto-fix.mjs
CHANGED
|
@@ -16,11 +16,13 @@ export function runAutoFixOnDocumentResult(docResult, { dryRun = false, backup =
|
|
|
16
16
|
(item.actionType === "replace" && item.suggestedReplacement !== "")),
|
|
17
17
|
);
|
|
18
18
|
|
|
19
|
+
const decisions = {};
|
|
19
20
|
if (safeItems.length === 0) {
|
|
20
21
|
return {
|
|
21
22
|
appliedCount: 0,
|
|
22
23
|
modified: false,
|
|
23
24
|
diff: "",
|
|
25
|
+
decisions,
|
|
24
26
|
report,
|
|
25
27
|
};
|
|
26
28
|
}
|
|
@@ -38,11 +40,23 @@ export function runAutoFixOnDocumentResult(docResult, { dryRun = false, backup =
|
|
|
38
40
|
displayPath: report.file,
|
|
39
41
|
});
|
|
40
42
|
|
|
43
|
+
let appliedCount = 0;
|
|
41
44
|
if (patchRes.modified && !dryRun) {
|
|
42
|
-
const
|
|
45
|
+
const appliedIdxSet =
|
|
46
|
+
patchRes.appliedIndices instanceof Set
|
|
47
|
+
? patchRes.appliedIndices
|
|
48
|
+
: new Set(safeItems.map((_, idx) => idx));
|
|
49
|
+
const appliedIds = new Set();
|
|
50
|
+
safeItems.forEach((item, idx) => {
|
|
51
|
+
if (appliedIdxSet.has(idx)) {
|
|
52
|
+
appliedIds.add(item.id);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
43
55
|
for (const item of items) {
|
|
44
56
|
if (appliedIds.has(item.id)) {
|
|
45
57
|
item._applied = true;
|
|
58
|
+
decisions[item.id] = "auto_applied";
|
|
59
|
+
appliedCount += 1;
|
|
46
60
|
}
|
|
47
61
|
}
|
|
48
62
|
const remaining = items.filter((i) => !i._applied);
|
|
@@ -51,9 +65,10 @@ export function runAutoFixOnDocumentResult(docResult, { dryRun = false, backup =
|
|
|
51
65
|
}
|
|
52
66
|
|
|
53
67
|
return {
|
|
54
|
-
appliedCount
|
|
68
|
+
appliedCount,
|
|
55
69
|
modified: patchRes.modified,
|
|
56
70
|
diff: patchRes.diff,
|
|
71
|
+
decisions,
|
|
57
72
|
report,
|
|
58
73
|
};
|
|
59
74
|
}
|
|
@@ -193,15 +193,16 @@ export async function runInteractiveTtySession(
|
|
|
193
193
|
const { doc, items, report } = docResult;
|
|
194
194
|
if (items.length === 0) {
|
|
195
195
|
stdout.write(`${report.file}: clean (0 items)\n`);
|
|
196
|
-
return { appliedCount: 0, modified: false, diff: "", report };
|
|
196
|
+
return { appliedCount: 0, modified: false, diff: "", decisions: {}, undoCount: 0, report };
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
let reader = keyReader || createKeypressQueue(stdin);
|
|
200
200
|
const ownedReader = !keyReader;
|
|
201
201
|
|
|
202
|
-
// Map itemIndex -> decision `{ status: 'accepted' | 'skipped' | 'edited', patch?: Object }`
|
|
202
|
+
// Map itemIndex -> decision `{ status: 'accepted' | 'skipped' | 'edited', copiedPrompt?: boolean, patch?: Object }`
|
|
203
203
|
let decisions = new Map();
|
|
204
204
|
const undoStack = [];
|
|
205
|
+
let undoCount = 0;
|
|
205
206
|
let idx = 0;
|
|
206
207
|
|
|
207
208
|
const snapshotState = () => {
|
|
@@ -221,7 +222,15 @@ export async function runInteractiveTtySession(
|
|
|
221
222
|
|
|
222
223
|
if (key === "\u0003") {
|
|
223
224
|
// Abort immediately without saving
|
|
224
|
-
return {
|
|
225
|
+
return {
|
|
226
|
+
appliedCount: 0,
|
|
227
|
+
modified: false,
|
|
228
|
+
diff: "",
|
|
229
|
+
aborted: true,
|
|
230
|
+
decisions: {},
|
|
231
|
+
undoCount,
|
|
232
|
+
report,
|
|
233
|
+
};
|
|
225
234
|
}
|
|
226
235
|
|
|
227
236
|
if (key === "q") {
|
|
@@ -235,6 +244,7 @@ export async function runInteractiveTtySession(
|
|
|
235
244
|
const prev = undoStack.pop();
|
|
236
245
|
idx = prev.idx;
|
|
237
246
|
decisions = prev.decisions;
|
|
247
|
+
undoCount += 1;
|
|
238
248
|
stdout.write(` (Reverted back to hunk ${idx + 1}.)\n`);
|
|
239
249
|
}
|
|
240
250
|
continue;
|
|
@@ -281,7 +291,7 @@ export async function runInteractiveTtySession(
|
|
|
281
291
|
stdout.write(` Rewrite prompt:\n ${promptText}\n`);
|
|
282
292
|
}
|
|
283
293
|
snapshotState();
|
|
284
|
-
decisions.set(idx, { status: "skipped" });
|
|
294
|
+
decisions.set(idx, { status: "skipped", copiedPrompt: true });
|
|
285
295
|
idx += 1;
|
|
286
296
|
continue;
|
|
287
297
|
}
|
|
@@ -427,7 +437,15 @@ export async function runInteractiveTtySession(
|
|
|
427
437
|
|
|
428
438
|
const patches = [];
|
|
429
439
|
const appliedIndices = new Set();
|
|
440
|
+
const decisionsSummary = {};
|
|
430
441
|
for (const [itemIdx, dec] of decisions.entries()) {
|
|
442
|
+
const itemId = items[itemIdx]?.id;
|
|
443
|
+
if (itemId) {
|
|
444
|
+
if (dec.status === "accepted") decisionsSummary[itemId] = "accepted";
|
|
445
|
+
else if (dec.status === "edited") decisionsSummary[itemId] = "edited";
|
|
446
|
+
else if (dec.copiedPrompt) decisionsSummary[itemId] = "prompt_copied";
|
|
447
|
+
else decisionsSummary[itemId] = "skipped";
|
|
448
|
+
}
|
|
431
449
|
if ((dec.status === "accepted" || dec.status === "edited") && dec.patch) {
|
|
432
450
|
patches.push(dec.patch);
|
|
433
451
|
appliedIndices.add(itemIdx);
|
|
@@ -436,7 +454,14 @@ export async function runInteractiveTtySession(
|
|
|
436
454
|
|
|
437
455
|
if (patches.length === 0) {
|
|
438
456
|
stdout.write("\nNo edits accepted; file left unchanged.\n");
|
|
439
|
-
return {
|
|
457
|
+
return {
|
|
458
|
+
appliedCount: 0,
|
|
459
|
+
modified: false,
|
|
460
|
+
diff: "",
|
|
461
|
+
decisions: decisionsSummary,
|
|
462
|
+
undoCount,
|
|
463
|
+
report,
|
|
464
|
+
};
|
|
440
465
|
}
|
|
441
466
|
|
|
442
467
|
const patchRes = patchDocumentOnDisk(doc, patches, { dryRun, backup });
|
|
@@ -456,6 +481,8 @@ export async function runInteractiveTtySession(
|
|
|
456
481
|
appliedCount: patchRes.modified ? patches.length : 0,
|
|
457
482
|
modified: patchRes.modified,
|
|
458
483
|
diff: patchRes.diff,
|
|
484
|
+
decisions: decisionsSummary,
|
|
485
|
+
undoCount,
|
|
459
486
|
report,
|
|
460
487
|
};
|
|
461
488
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import { formatDisplayCoordinate } from "../kernel/document-model.mjs";
|
|
3
3
|
import { applyPatchesToText, renderUnifiedDiff } from "../kernel/patcher.mjs";
|
|
4
|
+
import { DISLOP_VERSION } from "../kernel/version.mjs";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Render `--format json` (`dislop.report/1` verbatim for single file; array of `dislop.report/1` for multi-file).
|
|
@@ -25,9 +26,16 @@ export function formatAgentReports(results) {
|
|
|
25
26
|
(report.summary.suggestions.moderate || 0) +
|
|
26
27
|
(report.summary.suggestions.hint || 0);
|
|
27
28
|
|
|
29
|
+
const coverageNote =
|
|
30
|
+
report.coverage && report.coverage.segmentCount === 0 ? " coverage=0-segments" : "";
|
|
28
31
|
const lines = [
|
|
29
|
-
`# dislop file=${report.file} engine=${report.engine} defects=${defectTotal} suggestions=${suggestionTotal}`,
|
|
32
|
+
`# dislop file=${report.file} engine=${report.engine} defects=${defectTotal} suggestions=${suggestionTotal}${coverageNote}`,
|
|
30
33
|
];
|
|
34
|
+
if (report.coverage && report.coverage.segmentCount === 0) {
|
|
35
|
+
lines.push(
|
|
36
|
+
`# notice: ${report.coverage.notice || "0 inspectable text segments extracted; only container checks ran."}`,
|
|
37
|
+
);
|
|
38
|
+
}
|
|
31
39
|
|
|
32
40
|
for (const item of report.items) {
|
|
33
41
|
const coord = formatDisplayCoordinate(item.targetId, item.line);
|
|
@@ -110,7 +118,7 @@ export function formatSarifReports(results) {
|
|
|
110
118
|
tool: {
|
|
111
119
|
driver: {
|
|
112
120
|
name: "dislop",
|
|
113
|
-
version:
|
|
121
|
+
version: DISLOP_VERSION,
|
|
114
122
|
informationUri: "https://dislop.com",
|
|
115
123
|
rules: Array.from(rulesMap.values()),
|
|
116
124
|
},
|
|
@@ -182,6 +190,14 @@ export function formatTextReports(results, { lang = "en" } = {}) {
|
|
|
182
190
|
lines.push(` Tone: ${report.documentToneAnchor}`);
|
|
183
191
|
}
|
|
184
192
|
|
|
193
|
+
if (report.coverage && report.coverage.segmentCount === 0) {
|
|
194
|
+
lines.push(
|
|
195
|
+
lang === "zh"
|
|
196
|
+
? ` \u63d0\u793a: ${report.coverage.notice || "\u672a\u63d0\u53d6\u5230\u53ef\u5ba1\u8ba1\u6587\u672c\u6bb5\u843d\uff08\u53ef\u80fd\u662f\u626b\u63cf\u4ef6\u6216\u7eaf\u56fe\u7247\u5bb9\u5668\uff09\uff0c\u4ec5\u8fd0\u884c\u4e86\u5bb9\u5668\u5c42\u68c0\u67e5\u3002"}`
|
|
197
|
+
: ` Notice: ${report.coverage.notice || "0 inspectable prose segments extracted (scanned PDF or visual-only container); container-level checks only."}`,
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
|
|
185
201
|
if (defects.length === 0 && suggestions.length === 0) {
|
|
186
202
|
lines.push(
|
|
187
203
|
lang === "zh"
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { DISLOP_VERSION } from "../../kernel/version.mjs";
|
|
1
3
|
import { extractStructuredJson } from "../json-extract.mjs";
|
|
2
4
|
|
|
3
5
|
export const DEFAULT_CLOUD_REVIEW_URL = "https://dislop.com/api/v1/review";
|
|
@@ -31,14 +33,14 @@ export async function invokeCloudProvider({
|
|
|
31
33
|
headers: {
|
|
32
34
|
"Content-Type": "application/json",
|
|
33
35
|
Authorization: `Bearer ${token}`,
|
|
34
|
-
"User-Agent":
|
|
36
|
+
"User-Agent": `dislop-cli/${DISLOP_VERSION}`,
|
|
35
37
|
},
|
|
36
38
|
body: JSON.stringify({
|
|
37
39
|
schema: "dislop.review-request/1",
|
|
38
40
|
text: Array.isArray(doc?.segments)
|
|
39
41
|
? doc.segments.map((s) => s.text).join("\n\n")
|
|
40
42
|
: String(payload?.userPrompt || ""),
|
|
41
|
-
file: doc?.filePath || "",
|
|
43
|
+
file: path.basename(doc?.filePath || "document"),
|
|
42
44
|
format: doc?.format || "md",
|
|
43
45
|
modality: doc?.format || "md",
|
|
44
46
|
language: doc?.language || "en",
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { DislopConfigError } from "../../kernel/config.mjs";
|
|
4
|
+
import { extractHostname, isLoopbackHostname } from "../privacy-gate.mjs";
|
|
3
5
|
import { invokeOpenAiCompatProvider } from "./openai-compat.mjs";
|
|
4
6
|
|
|
5
7
|
export const LOCAL_MODEL_CATALOG = Object.freeze({
|
|
@@ -88,6 +90,12 @@ export function resolveInstalledLocalModel(config, env = process.env) {
|
|
|
88
90
|
const entry = manifest.installed[activeKey];
|
|
89
91
|
const baseUrl =
|
|
90
92
|
env.DISLOP_LOCAL_MODEL_URL || entry.baseUrl || "http://127.0.0.1:11434/v1";
|
|
93
|
+
const hostname = extractHostname(baseUrl);
|
|
94
|
+
if (!hostname || !isLoopbackHostname(hostname)) {
|
|
95
|
+
throw new DislopConfigError(
|
|
96
|
+
`Refusing non-loopback endpoint '${baseUrl}' for local model tier. Only localhost/127.0.0.1 are permitted in local mode.`,
|
|
97
|
+
);
|
|
98
|
+
}
|
|
91
99
|
|
|
92
100
|
return {
|
|
93
101
|
tier: "local",
|
package/src/runtime/router.mjs
CHANGED
|
@@ -161,7 +161,7 @@ export async function resolveExecutionRoute({
|
|
|
161
161
|
fetchImpl = globalThis.fetch,
|
|
162
162
|
promptFn = null,
|
|
163
163
|
}) {
|
|
164
|
-
if (config.noLlm) {
|
|
164
|
+
if (config.noLlm || config.routing === "off" || env.DISLOP_TEST_MODE === "1") {
|
|
165
165
|
return { tier: "none", engineLabel: "deterministic", maxInputTokens: 0, execute: null };
|
|
166
166
|
}
|
|
167
167
|
|
|
@@ -192,7 +192,7 @@ export async function resolveExecutionRoute({
|
|
|
192
192
|
"Engine 'byok' requires a configured provider in config.json or an OPENAI_API_KEY / ANTHROPIC_API_KEY / GEMINI_API_KEY environment variable.",
|
|
193
193
|
);
|
|
194
194
|
}
|
|
195
|
-
await checkPrivacyConsent({
|
|
195
|
+
const consent = await checkPrivacyConsent({
|
|
196
196
|
provider,
|
|
197
197
|
config,
|
|
198
198
|
isTty,
|
|
@@ -201,6 +201,11 @@ export async function resolveExecutionRoute({
|
|
|
201
201
|
stderr,
|
|
202
202
|
promptFn,
|
|
203
203
|
});
|
|
204
|
+
if (!consent || !consent.approved) {
|
|
205
|
+
throw new DislopConfigError(
|
|
206
|
+
consent?.reason || "BYOK external network upload cancelled or missing explicit consent.",
|
|
207
|
+
);
|
|
208
|
+
}
|
|
204
209
|
return buildTier2Route(provider, fetchImpl);
|
|
205
210
|
}
|
|
206
211
|
|
|
@@ -289,10 +294,12 @@ function buildTier2Route(provider, fetchImpl, labelPrefix = "byok") {
|
|
|
289
294
|
const protocol = String(provider.protocol || "openai").toLowerCase();
|
|
290
295
|
const engineLabel = `${labelPrefix}:${provider.model}`;
|
|
291
296
|
const maxInputTokens = provider.maxInputTokens || 16000;
|
|
297
|
+
const isLoopback = isLoopbackHostname(extractHostname(provider.baseUrl || ""));
|
|
292
298
|
|
|
293
299
|
if (protocol === "anthropic") {
|
|
294
300
|
return {
|
|
295
301
|
tier: labelPrefix,
|
|
302
|
+
isLoopback,
|
|
296
303
|
engineLabel,
|
|
297
304
|
maxInputTokens,
|
|
298
305
|
execute: (payload) => invokeAnthropicProvider({ provider, payload, fetchImpl }),
|
|
@@ -301,6 +308,7 @@ function buildTier2Route(provider, fetchImpl, labelPrefix = "byok") {
|
|
|
301
308
|
if (protocol === "gemini") {
|
|
302
309
|
return {
|
|
303
310
|
tier: labelPrefix,
|
|
311
|
+
isLoopback,
|
|
304
312
|
engineLabel,
|
|
305
313
|
maxInputTokens,
|
|
306
314
|
execute: (payload) => invokeGeminiProvider({ provider, payload, fetchImpl }),
|
|
@@ -308,6 +316,7 @@ function buildTier2Route(provider, fetchImpl, labelPrefix = "byok") {
|
|
|
308
316
|
}
|
|
309
317
|
return {
|
|
310
318
|
tier: labelPrefix,
|
|
319
|
+
isLoopback,
|
|
311
320
|
engineLabel,
|
|
312
321
|
maxInputTokens,
|
|
313
322
|
execute: (payload) => invokeOpenAiCompatProvider({ provider, payload, fetchImpl }),
|