返回目录
模型与 MCP 插件

dsh-terminal-render

LosEcher/dsh-terminal-render

Render DSH headless/CLI final output as readable terminal Markdown (CJK-aware ANSI) — zero-dependency, zero-harness-change plugin

Stars
0
Forks
0
Issues
0
更新
3 个月前

PROJECT TOPICS

项目标签

INSTALL REFERENCE

安装参考

未验证
dsh plugin --profile web add github:LosEcher/dsh-terminal-render

该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。

PROJECT README

README

dsh-terminal-render

Render DSH headless / CLI final output as readable terminal Markdown.

dsh --profile headless "task" currently prints the final assistant message as raw Markdown source (**bold**, | tables |, # headings, …), which is unreadable in a terminal. This plugin wraps process.stdout.write once at tree mount so any Markdown-looking write is rendered to ANSI (CJK-aware) before it reaches the terminal — with zero changes to the harness.

Why this works without touching DSH

The headless bundle (@deepseek-ai/dsh-headless) builds its IO as { stdout: internals.stdout, ... } where internals.stdout is the process.stdout object, captured by reference. The final message is written through process.stdout.write(outcome.text). Wrapping that method therefore intercepts the output regardless of plugin load order.

CJK compatibility (the point of this plugin)

CommonMark's flanking rules and byte-oriented parsers mis-handle CJK prose, which has no spaces between words:

  • **加粗**,中文 — strong must close before a fullwidth comma / CJK char (same rule as DSH web's cjkFriendlyStrong micromark extension).
  • 中文**加粗** — emphasis must open/close with CJK neighbors.
  • CJK chars are 2 display cells: table columns are aligned by display width (unicode-width semantics), not byte count.
  • Only ~~…~~ is strikethrough; single ~text~ stays literal so LLM output like ~**10%** ("approximately") is not struck (grok-build strategy).

Usage

# After wiring into the headless profile (see below):
dsh --profile headless "list my todos"     # rendered, when stdout is a TTY
dsh --profile headless "…" | cat           # passthrough (not a TTY)

Env controls:

Variable Effect
NO_COLOR Disable rendering entirely (plain passthrough).
DSH_TERMINAL_RENDER=0 Force plain passthrough even for Markdown text (piping).
DSH_TERMINAL_RENDER=1 Force rendering even without a TTY.
DSH_TERMINAL_LINKS=0 Disable OSC 8 hyperlinks.

Rendering capabilities

  • Headings #–###### (colored + bold), --- rules
  • strong, emphasis, inline code, strike (double-tilde only)
  • [text](url) links with OSC 8 hyperlinks (plain (url) suffix fallback)
  • Tables with box borders, display-width-aligned columns, per-cell alignment (:---:, ---:, :---), CJK-aware wrapping
  • Unordered/ordered/task lists (- [x]), blockquotes
  • Fenced code blocks (language tag in the header, body in reverse video)
  • LaTeX-friendly literals: no KaTeX, but single-tilde demotion avoids strike-through surprises

Wiring into the headless profile

Add to ~/.dsh/profiles/headless/cordis.patch.yml:

- insert:
    - id: terminal-render
      name: dsh-terminal-render

and to ~/.dsh/profiles/headless/package.json dependencies:

"dsh-terminal-render": "github:LosEcher/dsh-terminal-render#main"

(During local development use "link:/absolute/path/to/dsh-terminal-render" instead, then pnpm install in the profile and run a headless task.)

Wiring into the web profile

Same pattern in ~/.dsh/profiles/web/cordis.patch.yml and ~/.dsh/profiles/web/package.json; restart the web host afterwards.

Development

node --check lib/render.js
node --check lib/index.js
node test/run.mjs          # 27 assertions: widths, inline, blocks, detection

License

MIT

CLASSIFICATION EVIDENCE

分类依据

项目类型插件
功能分类模型与 MCP
规则置信度中

系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek-harness。