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
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
## 常见问题与改法
|
|
7
7
|
|
|
8
|
-
1. **保持长短句自然错落(`
|
|
9
|
-
2.
|
|
10
|
-
3.
|
|
11
|
-
4. **停在最后一个现场画面,别强行升华(`
|
|
12
|
-
5. **纠回中文标点、否定转折腔与生硬译文腔(`
|
|
8
|
+
1. **保持长短句自然错落(`stealth-vapor`、`hollow-transition`)**:避免连续 5 句以上长度接近、缺少具体名词的空句子。按时间、地点和动作自然展开,不刻意切碎成三字短句口号。
|
|
9
|
+
2. **删掉设问过渡与宏大套话(`rhetorical-self-qa`、`hollow-transition`)**:删去 `为什么这一点如此重要?`、`这意味着什么?`、`在当今……浪潮下` 以及工整排比的三段分号句。
|
|
10
|
+
3. **只在失控长句处拆句**:一逗到底超过五六个分句且主语不清时再拆成 2 到 3 句,本身节奏通顺的流水句无需强行拆断。
|
|
11
|
+
4. **停在最后一个现场画面,别强行升华(`moralizing-closer`、`hollow-transition`)**:删掉 `在当今……` 开头和 `这或许就是……真正的意义所在` 结尾,落在最后一个动作或原话直接收笔。
|
|
12
|
+
5. **纠回中文标点、否定转折腔与生硬译文腔(`halfwidth-cjk-punctuation`、`unprompted-negation`)**:中文正文统一用全角逗号、句号和引号,删掉无语境支撑的 `不是……而是……` 句式,并避开生硬的欧化状语堆砌。
|
|
13
13
|
6. **只写笔记实情**:用素材已有的器物、动作、天气和对话自然展开来匹配目标篇幅,绝不外编路人、对话或心理活动凑字数。
|
|
14
14
|
|
|
15
15
|
## 三段对照
|
|
@@ -5,11 +5,11 @@ CLI check: `dislop check <file.docx-or-pptx> --format agent` (mounts `slide-deck
|
|
|
5
5
|
|
|
6
6
|
## Rules & Fixes
|
|
7
7
|
|
|
8
|
-
1. **Strip leaked Markdown
|
|
8
|
+
1. **Strip leaked Markdown, chat wrappers & placeholders (`raw-markdown-leak`, `chatbot-artifact`, `unfilled-placeholder`, `leaked-slide-directive`)**: Remove `**bold**`, `## Heading`, backticks, placeholder tags, `[Image suggestion: ...]`, and conversational wrapper sentences. Delete wrapper nouns whole—never glue partial headings onto body sentences.
|
|
9
9
|
2. **Keep XML structure, document-API styles & grammar intact**: Preserve valid XML tags (`<w:document>`, `<p:sld>`), document-API paragraph styles, tracked changes (`<w:ins>`, `<w:del>`), comments, and tables. Leave existing text runs and split numbers intact (for example `$18.` + `5M`) unless merging is necessary; after cutting hype modifiers (`Their faultless backup cluster`), keep determiner grammar intact (`Their backup cluster`).
|
|
10
|
-
3. **Write finding headlines (`slide-
|
|
11
|
-
4. **Keep slides scannable without repeating numbers (`slide-word-wall`, `slide-bullet-overload`, `slide-autofit-shrink`)**: When drafting slides, stay within 120 words and 5–6 bullets without `<a:normAutofit fontScale="65000"/>`, and avoid repeating the headline number inside bullets. When revising, keep all source facts intact.
|
|
12
|
-
5. **Break consecutive bullet skeletons (`
|
|
10
|
+
3. **Write finding headlines (`buzzword-slide-headline`, `vague-slide-headline`, `closing-slide-slogan`)**: Replace generic headings (`"Overview"`, `"Strategic Synergy"`) with the specific finding and source number (`"North Pier Pump Drew $42k Excess Power"`), and drop closing slogan slides.
|
|
11
|
+
4. **Keep slides scannable without repeating numbers (`slide-word-wall`, `slide-bullet-overload`, `slide-autofit-shrink`, `slide-prose-dump`)**: When drafting slides, stay within 120 words and 5–6 bullets without `<a:normAutofit fontScale="65000"/>`, and avoid repeating the headline number inside bullets. When revising, keep all source facts intact.
|
|
12
|
+
5. **Break consecutive bullet skeletons (`repetitive-slide-skeleton`)**: Across 4+ slides, vary layouts with tables for comparisons and charts for trends, and strip image workflow metadata (`image-ai-workflow-residue`).
|
|
13
13
|
|
|
14
14
|
## Contrast
|
|
15
15
|
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
## 常见问题与改法
|
|
7
7
|
|
|
8
|
-
1. **清掉裸 Markdown、寒暄与占位符(`markdown-leak`、`chatbot-artifact`、`unfilled-placeholder`)**:删掉 `**加粗**`、`## 标题`、`[待补充]` 和整句模型寒暄(如 `很高兴协助,下方是……`)。寒暄里的名词整句删掉,不要硬粘成 `总体说明:` 这类半截小标题。
|
|
8
|
+
1. **清掉裸 Markdown、寒暄与占位符(`raw-markdown-leak`、`chatbot-artifact`、`unfilled-placeholder`、`leaked-slide-directive`)**:删掉 `**加粗**`、`## 标题`、`[待补充]`、`[配图建议:...]` 和整句模型寒暄(如 `很高兴协助,下方是……`)。寒暄里的名词整句删掉,不要硬粘成 `总体说明:` 这类半截小标题。
|
|
9
9
|
2. **保住 XML 标签、文档接口样式与语法完整**:修改原始 XML 或通过办公软件文档接口编辑时,保持 `<w:document>/<w:body>/<w:p>/<w:r>/<w:t>` 等标签配平,保留审阅修订、批注、段落样式与真实表格。默认保留原有的 `<w:t>` / `<a:t>` 分段边界,留意跨节点拆开的数字(如 `84.` 与 `6 万千瓦时`)和前面限定词;删掉虚高修饰词后检查主语和限定词是否通顺。
|
|
10
|
-
3. **把弱标签改成结论标题(`slide-
|
|
11
|
-
4. **控住新建幻灯片密度且不重复数字(`slide-word-wall`、`slide-bullet-overload`、`slide-autofit-shrink`)**:起草单页控制在 120 字和 5–6 条要点以内,不用缩排硬塞,标题写过的数字不要在要点里反复重复;改旧稿时不要为了凑字数删掉原稿事实。
|
|
12
|
-
5. **打破连续同构模板页(`
|
|
10
|
+
3. **把弱标签改成结论标题(`buzzword-slide-headline`、`vague-slide-headline`、`closing-slide-slogan`)**:把 `顶层设计与生态赋能`、`项目整体概况` 改成一句带数据的结论(如 `西站 6 号闸机早高峰积压 18 分钟`),并清掉 `携手并进,共创辉煌未来!` 类口号末页。
|
|
11
|
+
4. **控住新建幻灯片密度且不重复数字(`slide-word-wall`、`slide-bullet-overload`、`slide-autofit-shrink`、`slide-prose-dump`)**:起草单页控制在 120 字和 5–6 条要点以内,不用缩排硬塞,标题写过的数字不要在要点里反复重复;改旧稿时不要为了凑字数删掉原稿事实。
|
|
12
|
+
5. **打破连续同构模板页(`repetitive-slide-skeleton`)**:不要连续 4 页全放纯文字要点,对比改表格、趋势改图表;配图同步清掉生成工具工作流元数据(`image-ai-workflow-residue`)。
|
|
13
13
|
|
|
14
14
|
## 三段对照
|
|
15
15
|
|
|
@@ -5,9 +5,9 @@ CLI check: `dislop check <dir> --pack web-ui --format agent`
|
|
|
5
5
|
|
|
6
6
|
## Rules & Fixes
|
|
7
7
|
|
|
8
|
-
1. **Zero dead controls (`
|
|
9
|
-
2. **Skip stock AI chrome (`
|
|
10
|
-
3. **Skip secondary fallback templates (`
|
|
8
|
+
1. **Zero dead controls (`placeholder-dead-link`, `empty-link-target`, `unexplained-disabled-button`, `svg-missing-viewbox`, severity `error`)**: Never emit `<a href="#">`, empty `href=""`, `<svg>` missing `viewBox`, or unexplained `<button disabled>`. Wire only real routes from the codebase or prompt; if an action is unbuilt, omit the control or explain why it is disabled with visible text linked via `aria-describedby`.
|
|
9
|
+
2. **Skip stock AI chrome (`neon-ai-gradient`, `glow-blob-backdrop`, `pill-badge-soup`, `prompt-echo-copy`, `emoji-feature-grid`)**: Avoid indigo-purple-pink neon gradients, `blur-3xl` glow orbs, `> 6` `rounded-full` pills per view, decorative emoji headings, and `"AI-Powered"` or `"Supercharge Your Workflow"` copy.
|
|
10
|
+
3. **Skip secondary fallback templates (`glassmorphism-overuse`, `placeholder-ui-copy`, `synthetic-testimonial-cliche`, `fabricated-stat-tile`, `redundant-feature-card-echo`, `verbose-cta-label`)**: Do not replace neon gradients with stacked `backdrop-blur` translucent cards, placeholder subcopy, fabricated stats, or chatty CTA labels.
|
|
11
11
|
4. **Use clean structural grammar**: Use `1px` rules, clear type scale, `tabular-nums` for aligned metrics, and restrained radii (`0–6px`). When revising existing UI, fix flagged issues in place without redesigning working layout or wrapping a snippet prompt in a full `<!DOCTYPE html>` shell unless asked.
|
|
12
12
|
5. **Keep UI copy exact**: State only requested labels, counts, states, and existing routes without inventing headings or file names.
|
|
13
13
|
6. **Respect non-UI graphic deliverables (posters, infographics, flowcharts, diagrams, comics)**: Standalone posters are not slide decks—never recommend moving text to speaker notes; open diagram connectors and feedback loops are structural graph edges, never treat them as nested `box-in-box` UI chrome or delete return arrows; keep explicit warm-paper or dark palettes when chosen intentionally.
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
## 常见问题与改法
|
|
7
7
|
|
|
8
|
-
1. **清零死控件(`
|
|
9
|
-
2. **去掉第一代默认 AI 模板(`
|
|
10
|
-
3. **别退回第二代替代模板(`
|
|
8
|
+
1. **清零死控件(`placeholder-dead-link`、`empty-link-target`、`unexplained-disabled-button`、`svg-missing-viewbox`,硬伤)**:禁止输出 `<a href="#">`、空链接、缺少 `viewBox` 的 `<svg>`,或没有原因说明的 `<button disabled>`。链接只填需求或代码库里真实存在的路径;未实现的功能直接删掉按钮,或用可见说明文字配 `aria-describedby` 写清禁用原因。
|
|
9
|
+
2. **去掉第一代默认 AI 模板(`neon-ai-gradient`、`glow-blob-backdrop`、`pill-badge-soup`、`prompt-echo-copy`、`emoji-feature-grid`)**:不用蓝紫粉霓虹渐变、弥散发光光斑、单屏超过 6 个圆角胶囊标签、标题前置装饰 Emoji,以及 `AI 强力驱动`、`开启新纪元` 类空洞套话。
|
|
10
|
+
3. **别退回第二代替代模板(`glassmorphism-overuse`、`placeholder-ui-copy`、`synthetic-testimonial-cliche`、`fabricated-stat-tile`、`redundant-card-subcopy`、`verbose-cta-label`)**:不要把紫粉渐变换成满屏半透明毛玻璃卡片、占位假文案、无来源背书数据、同义重复卡片描述或冗长客套按钮文案。
|
|
11
11
|
4. **用克制的版面结构呈现数据**:用 `1px` 细线、清晰字号层级与 `tabular-nums` 等宽数字对齐指标,保持按钮与面板克制圆角(`0–6px`)。要求输出片段时直接给组件片段,不要擅自套整页 `<!DOCTYPE html>` 壳;改旧页面时保留本来正常的布局,不无故重做。
|
|
12
12
|
5. **界面文案直说数字和路径**:只写需求给出的文案标签、计数、状态与真实路径,不塞宣传口号,不自己编维护时间或导出文件名。
|
|
13
13
|
6. **区分网页组件与海报/信息图/流程图/条漫**:单张海报或信息图不是演示文稿,不要建议“挪进演讲备注”;流程图里的开放连线和反馈回流箭头是结构关系,不要误判成多层套盒或建议删线;刻意设计的暖宣纸、暗底配色与漫画气泡予以保留。
|
|
@@ -5,12 +5,12 @@ CLI check: `dislop check <path> --format agent` (verify edits via `dislop verify
|
|
|
5
5
|
|
|
6
6
|
## Rules & Fixes
|
|
7
7
|
|
|
8
|
-
1. **Strip chat wrappers
|
|
9
|
-
2. **Cut macro preambles & future-gazing (`
|
|
10
|
-
3. **Break low-fact buzzword clusters (`cooccurrence-
|
|
11
|
-
4. **Keep PRs, CLI copy & postmortems factual (`
|
|
12
|
-
5. **Cut absolute claims & unanchored multipliers
|
|
13
|
-
6. **No invented attribution or bold list walls (`
|
|
8
|
+
1. **Strip chat wrappers, citations, placeholders & broken links (`chatbot-artifact`, `chatbot-citation-leak`, `unfilled-placeholder`, `broken-local-link`, `disguised-placeholder-prose`, `unchosen-draft-options`)**: Delete opening conversational scaffolding, `[oaicite:1]` leaks, `[TBD]` markers, author-facing reminders, and unchosen `Option A / Option B` branches; start directly on the ticket, release, or decision.
|
|
9
|
+
2. **Cut macro preambles, throat-clearing & future-gazing (`hollow-transition`, `throat-clearing`, `moralizing-closer`)**: Drop trend openings (`"In today's fast-paced world..."`), `"It is worth noting that..."`, and vague outlooks (`"Looking ahead..."`).
|
|
10
|
+
3. **Break low-fact buzzword clusters (`cooccurrence-hype-cluster`, `stealth-vapor`)**: Replace stacked filler verbs (`harnesses`, `elevate`, `streamline`, `unlock potential`) with the exact mechanism stated in the notes.
|
|
11
|
+
4. **Keep PRs, CLI copy & postmortems factual (`unprompted-negation`, `rhetorical-self-qa`)**: Copy owners, flags, thresholds, and due dates verbatim; list missing ones as open questions. State the missing check or recovery step directly instead of writing `"This isn't just X — it's Y"` or `"Why does this matter?"`.
|
|
12
|
+
5. **Cut absolute claims & unanchored multipliers**: Delete unproven absolutes (`"always guaranteed"`, `"never fails"`) and bare multipliers (`"5x speed gain"`); cite a standard or baseline only when present in the source, and keep hedging words like `projected` intact.
|
|
13
|
+
6. **No invented attribution or bold list walls (`bold-lead-list-wall`)**: Drop filler such as `"Studies show"`, keep source evidence labels (`benchmarked`, `measured`) without upgrading them, and turn stacked `- **Label**: text` lists (`4+` items) into plain prose.
|
|
14
14
|
7. **Honest edits only**: Remove real filler while keeping every distinct point and mechanism intact; never compress multi-paragraph prose into a stub or add fake typos.
|
|
15
15
|
|
|
16
16
|
## Contrast
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
|
|
6
6
|
## 常见问题与改法
|
|
7
7
|
|
|
8
|
-
1.
|
|
9
|
-
2.
|
|
10
|
-
3. **拆散公文黑话与四字排比(`
|
|
11
|
-
4. **改实研发复盘、CLI 文案与改进项(`
|
|
12
|
-
5.
|
|
13
|
-
6. **保留原始出处标签,别堆加粗列表,别缩成残句(`
|
|
8
|
+
1. **清掉寒暄壳、引用泄漏、占位符与死链(`chatbot-artifact`、`chatbot-citation-leak`、`unfilled-placeholder`、`broken-local-link`、`disguised-placeholder-prose`、`unchosen-draft-options`)**:删掉 `你好,下面为你附上……`、`[oaicite:1]`、`[待填写]`、正文里的待办提醒与未定稿的 `方案 A / 方案 B`,第一句落到具体模块、单号或数字。
|
|
9
|
+
2. **删掉宏大空话、句首铺垫与口号结尾(`hollow-transition`、`throat-clearing`、`moralizing-closer`)**:删去 `在当今……浪潮下`、`值得注意的是,`、`展望未来……`、`这标志着……`。
|
|
10
|
+
3. **拆散公文黑话与四字排比(`four-char-slogan-triad`、`buzzword-cluster`、`cooccurrence-padding`)**:把 `重要抓手`、`全面赋能`、`精准高效、安全可靠、灵活易用`、`深度融合、充分释放` 换成笔记里的真实动作。
|
|
11
|
+
4. **改实研发复盘、CLI 文案与改进项(`unprompted-negation`、`rhetorical-self-qa`)**:笔记给了负责人、命令参数、阈值和日期就照抄;没给就单独列为待确认问题。直接写缺了哪道校验或具体排查步骤,不要写 `这不是……而是……` 或 `为什么这一点如此重要?`。
|
|
12
|
+
5. **删掉绝对承诺与悬空倍数**:删掉 `绝对安全`、`永不宕机`、`倍速跃升`;原文给了加密协议、合同可用性、预计目标或前后基线才保留。
|
|
13
|
+
6. **保留原始出处标签,别堆加粗列表,别缩成残句(`bold-lead-list-wall`)**:只删模型自己加的 `业内普遍认为` 等空壳背书;笔记里原有 `实测结果` 时直接写结论(如 `升级后……`),不添 `上线后实测`,也别把短列表全堆成 5 条及以上 `- **标签**:内容`;删掉空话时保留原句每个独立动作与数字,别硬压缩成一句话。
|
|
14
14
|
|
|
15
15
|
## 三段对照
|
|
16
16
|
|
package/src/cli-main.mjs
CHANGED
|
@@ -7,11 +7,13 @@ import { runModelCommand } from "./commands/model.mjs";
|
|
|
7
7
|
import { runPacksCommand } from "./commands/packs.mjs";
|
|
8
8
|
import { runVerifyCommand } from "./commands/verify.mjs";
|
|
9
9
|
import { runVoiceCommand } from "./commands/voice.mjs";
|
|
10
|
+
import { runWorklogCommand } from "./commands/worklog.mjs";
|
|
10
11
|
import { DislopConfigError } from "./kernel/config.mjs";
|
|
12
|
+
import { DISLOP_VERSION } from "./kernel/version.mjs";
|
|
11
13
|
import { startStdioMcpServer } from "./mcp/stdio-server.mjs";
|
|
12
14
|
import { detectOllamaBinary } from "./runtime/providers/local-model.mjs";
|
|
13
15
|
|
|
14
|
-
export const CLI_VERSION =
|
|
16
|
+
export const CLI_VERSION = DISLOP_VERSION;
|
|
15
17
|
|
|
16
18
|
export function buildHelpText(env = process.env) {
|
|
17
19
|
const ollama = detectOllamaBinary(env);
|
|
@@ -31,21 +33,27 @@ Usage:
|
|
|
31
33
|
dislop logout Remove saved Official Cloud credentials
|
|
32
34
|
dislop voice <extract|show|clear> [files] Manage personal voice baseline (voice.json)
|
|
33
35
|
dislop model <list|pull|rm> [name] Manage Tier 3 local models (requires Ollama)
|
|
34
|
-
dislop packs [--json]
|
|
36
|
+
dislop packs [list|lint <path>] [--json] List built-in Packs or lint external .pack.md / Pack dirs
|
|
35
37
|
dislop doctor [--json] Inspect active routing tier, Ollama status, auth, config, and Packs
|
|
38
|
+
dislop worklog <status|list|show|stats|reflect|clear> Inspect local dev worklog & reflection summaries
|
|
36
39
|
dislop mcp Start local stdio MCP server for coding & office agents
|
|
37
40
|
|
|
38
41
|
Options (check / fix):
|
|
39
42
|
--auto, -y (fix only) Apply verified fixSafety === "safe" items non-interactively
|
|
40
43
|
--json Emit pure dislop.report/1 JSON to stdout (diagnostics to stderr)
|
|
41
44
|
--format <text|diff|json|agent|sarif> Output format ('agent' = token-compact feed for AI agents)
|
|
45
|
+
--stdin-filename <name> Filename/extension hint when reading document from stdin ('-')
|
|
46
|
+
--changed Inspect git-modified, staged, and untracked deliverable files
|
|
47
|
+
--since <ref> Inspect deliverable files changed since git <ref>
|
|
48
|
+
--fail-on <none|error|warning> Minimum Defect severity to fail with Exit 1 (default: error; Suggestions always Exit 0)
|
|
42
49
|
--pack <names/paths...> Mount specific Packs (comma-separated or repeated)
|
|
43
50
|
--no-llm Run deterministic Script Packs (pack.check) only
|
|
44
51
|
--voice <files/globs...> Align review with hand-written voice reference files
|
|
45
52
|
--level <strong|moderate|hint|all> Filter Suggestion priority threshold (default: all)
|
|
46
|
-
--engine <local|auto|cloud|byok>
|
|
53
|
+
--engine <off|local|auto|cloud|byok> Routing tier (default: local; Tier 3 local LLM requires Ollama)
|
|
47
54
|
--provider <name> Select named or built-in provider (openai, anthropic, gemini)
|
|
48
55
|
--model <name> Override LLM model identifier for the active provider
|
|
56
|
+
--concurrency <n> Max parallel files during 'check' (1-16; default 4 for LLM)
|
|
49
57
|
--dry-run Preview unified diff without modifying files on disk
|
|
50
58
|
--backup Create <file>.bak before atomic write
|
|
51
59
|
--lang <auto|en|zh> Diagnostic language ('auto' matches target document language)
|
|
@@ -74,6 +82,46 @@ function splitCommaValues(values) {
|
|
|
74
82
|
.filter(Boolean);
|
|
75
83
|
}
|
|
76
84
|
|
|
85
|
+
const OPTIONS_WITH_VALUE = new Set([
|
|
86
|
+
"--format",
|
|
87
|
+
"--pack",
|
|
88
|
+
"--voice",
|
|
89
|
+
"--level",
|
|
90
|
+
"--engine",
|
|
91
|
+
"--provider",
|
|
92
|
+
"--model",
|
|
93
|
+
"--concurrency",
|
|
94
|
+
"--lang",
|
|
95
|
+
"--token",
|
|
96
|
+
"--endpoint",
|
|
97
|
+
"--since",
|
|
98
|
+
"--fail-on",
|
|
99
|
+
"--stdin-filename",
|
|
100
|
+
"--days",
|
|
101
|
+
"--limit",
|
|
102
|
+
"--command",
|
|
103
|
+
"--older-than",
|
|
104
|
+
]);
|
|
105
|
+
|
|
106
|
+
function countRemainingPositionals(tokens, startIndex) {
|
|
107
|
+
let count = 0;
|
|
108
|
+
for (let j = startIndex; j < tokens.length; j += 1) {
|
|
109
|
+
const tok = tokens[j];
|
|
110
|
+
if (tok === "--") {
|
|
111
|
+
count += tokens.length - j - 1;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
if (tok.startsWith("-")) {
|
|
115
|
+
if (OPTIONS_WITH_VALUE.has(tok) && !tok.includes("=")) {
|
|
116
|
+
j += 1;
|
|
117
|
+
}
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
count += 1;
|
|
121
|
+
}
|
|
122
|
+
return count;
|
|
123
|
+
}
|
|
124
|
+
|
|
77
125
|
/**
|
|
78
126
|
* Parse CLI arguments and execute the requested `dislop` subcommand.
|
|
79
127
|
* Returns integer process exit code (`0`, `1`, or `2`).
|
|
@@ -89,9 +137,9 @@ export async function runCli(argv = process.argv.slice(2), io = {}) {
|
|
|
89
137
|
const arg = argv[i];
|
|
90
138
|
if (arg === "--git") {
|
|
91
139
|
const next = argv[i + 1];
|
|
92
|
-
//
|
|
93
|
-
const
|
|
94
|
-
if (next && !next.startsWith("-") &&
|
|
140
|
+
// If another positional target follows `next`, `next` is the git ref; otherwise default to `HEAD`
|
|
141
|
+
const remainingAfterNext = next ? countRemainingPositionals(argv, i + 2) : 0;
|
|
142
|
+
if (next && !next.startsWith("-") && remainingAfterNext >= 1) {
|
|
95
143
|
normalizedArgv.push(`--git=${next}`);
|
|
96
144
|
i += 1;
|
|
97
145
|
} else {
|
|
@@ -115,6 +163,13 @@ export async function runCli(argv = process.argv.slice(2), io = {}) {
|
|
|
115
163
|
yes: { type: "boolean", short: "y" },
|
|
116
164
|
json: { type: "boolean" },
|
|
117
165
|
format: { type: "string" },
|
|
166
|
+
"stdin-filename": { type: "string" },
|
|
167
|
+
changed: { type: "boolean" },
|
|
168
|
+
since: { type: "string" },
|
|
169
|
+
"fail-on": { type: "string" },
|
|
170
|
+
patterns: { type: "boolean" },
|
|
171
|
+
ml: { type: "boolean" },
|
|
172
|
+
deep: { type: "boolean" },
|
|
118
173
|
pack: { type: "string", multiple: true },
|
|
119
174
|
"no-llm": { type: "boolean" },
|
|
120
175
|
voice: { type: "string", multiple: true },
|
|
@@ -122,6 +177,7 @@ export async function runCli(argv = process.argv.slice(2), io = {}) {
|
|
|
122
177
|
engine: { type: "string" },
|
|
123
178
|
provider: { type: "string" },
|
|
124
179
|
model: { type: "string" },
|
|
180
|
+
concurrency: { type: "string" },
|
|
125
181
|
"dry-run": { type: "boolean" },
|
|
126
182
|
backup: { type: "boolean" },
|
|
127
183
|
lang: { type: "string" },
|
|
@@ -130,6 +186,10 @@ export async function runCli(argv = process.argv.slice(2), io = {}) {
|
|
|
130
186
|
token: { type: "string" },
|
|
131
187
|
endpoint: { type: "string" },
|
|
132
188
|
git: { type: "string" },
|
|
189
|
+
days: { type: "string" },
|
|
190
|
+
limit: { type: "string" },
|
|
191
|
+
command: { type: "string" },
|
|
192
|
+
"older-than": { type: "string" },
|
|
133
193
|
},
|
|
134
194
|
});
|
|
135
195
|
} catch (err) {
|
|
@@ -138,6 +198,17 @@ export async function runCli(argv = process.argv.slice(2), io = {}) {
|
|
|
138
198
|
|
|
139
199
|
const { values, positionals } = parsed;
|
|
140
200
|
|
|
201
|
+
if (values.patterns) {
|
|
202
|
+
throw new DislopConfigError(
|
|
203
|
+
"Flag '--patterns' was removed in dislop v1.x. Use '--pack <names>' (for example '--pack en/prose' or '--pack common/artifact-qa').",
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
if (values.ml || values.deep) {
|
|
207
|
+
throw new DislopConfigError(
|
|
208
|
+
"Flags '--ml' and '--deep' were removed in dislop v1.x. Use '--engine <auto|local|cloud|byok>' or '--no-llm'.",
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
141
212
|
if (values.version) {
|
|
142
213
|
stdout.write(`${CLI_VERSION}\n`);
|
|
143
214
|
return 0;
|
|
@@ -163,14 +234,23 @@ export async function runCli(argv = process.argv.slice(2), io = {}) {
|
|
|
163
234
|
engine: values.engine || null,
|
|
164
235
|
provider: values.provider || null,
|
|
165
236
|
model: values.model || null,
|
|
237
|
+
concurrency: values.concurrency || null,
|
|
166
238
|
dryRun: Boolean(values["dry-run"]),
|
|
167
239
|
backup: Boolean(values.backup),
|
|
168
240
|
lang: values.lang || null,
|
|
241
|
+
stdinFilename: values["stdin-filename"] || null,
|
|
242
|
+
changed: Boolean(values.changed),
|
|
243
|
+
since: values.since || null,
|
|
244
|
+
failOn: values["fail-on"] || null,
|
|
169
245
|
global: Boolean(values.global),
|
|
170
246
|
force: Boolean(values.force),
|
|
171
247
|
token: values.token || null,
|
|
172
248
|
endpoint: values.endpoint || null,
|
|
173
249
|
git: values.git,
|
|
250
|
+
days: values.days || null,
|
|
251
|
+
limit: values.limit || null,
|
|
252
|
+
command: values.command || null,
|
|
253
|
+
olderThan: values["older-than"] || null,
|
|
174
254
|
};
|
|
175
255
|
|
|
176
256
|
switch (subcommand) {
|
|
@@ -194,6 +274,8 @@ export async function runCli(argv = process.argv.slice(2), io = {}) {
|
|
|
194
274
|
return await runPacksCommand(restPositionals, flags, io);
|
|
195
275
|
case "doctor":
|
|
196
276
|
return await runDoctorCommand(restPositionals, flags, io);
|
|
277
|
+
case "worklog":
|
|
278
|
+
return await runWorklogCommand(restPositionals, flags, io);
|
|
197
279
|
case "mcp":
|
|
198
280
|
startStdioMcpServer(io);
|
|
199
281
|
return 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
|
}
|